parser/calc/parser.y
changeset 38 48f6f3918b82
parent 37 0fbbe329c3a2
child 39 46d7ec9d63bd
--- a/parser/calc/parser.y
+++ b/parser/calc/parser.y
@@ -7,9 +7,9 @@
    #include <stdio.h>
    #include <ctype.h>
 
-   int regs[26]; 
+   int regs[26];
    int base;
-	
+
    int yyerror();
    int yylex();
 %}
@@ -20,65 +20,67 @@
 %left UMINUS
 %%
 
-list : /* empty */ 
-	| list stat '\n' 
+list:
+	/* empty */
+	| list stat '\n'
 	| list error '\n' { yyerrok; };
 
-stat : 
-	expr { (void) printf( "RESULT: %d\n", $1 ); } 
+stat:
+	expr { (void) printf( "RESULT: %d\n", $1 ); }
 	| LETTER '=' expr { regs[$1] = $3; }
 	;
 
-   expr      :  '(' expr ')'
-             {
-                   $$ = $2;
-             }
-             |  expr PLUS expr
-             {
-                   $$ = $1 + $3;
-             }
-             |  expr MINUS expr
-             {
-                   $$ = $1 - $3;
-             }
-             |  expr MUL expr
-             { 
-                   $$ = $1 * $3;
-             }
-             |  expr DIV expr
-             {
-                   $$ = $1 / $3;
-             }
-             |  MINUS expr  %prec UMINUS
-             {
-                   $$ = -$2;
-             }
-             |  LETTER
-             {
-                   $$ = regs[$1];
-             }
-             |  number
-             ;
+expr:
+	'(' expr ')'
+	{
+		$$ = $2;
+	}
+	| expr PLUS expr
+	{
+		$$ = $1 + $3;
+	}
+	| expr MINUS expr
+	{
+		$$ = $1 - $3;
+	}
+	| expr MUL expr
+	{
+		$$ = $1 * $3;
+	}
+	| expr DIV expr
+	{
+			$$ = $1 / $3;
+	}
+	| MINUS expr  %prec UMINUS
+	{
+		$$ = -$2;
+	}
+	| LETTER
+	{
+		$$ = regs[$1];
+	}
+	|  number
+	;
 
-   number    :   DIGIT
-             {
-                    $$ = $1; base = ($1==0) ? 8 : 10;
-             }
-             |   number DIGIT
-             {
-                    $$ = base * $1 + $2;
-             }
-             ;
-   
+number:
+	DIGIT
+	{
+		$$ = $1; base = ($1==0) ? 8 : 10;
+	}
+	| number DIGIT
+	{
+		$$ = base * $1 + $2;
+	}
+	;
 %%
 
-int yyerror() 
+int yyerror()
 {
 	printf("ERROR\n");
 	return 0;
 }
 
-int yywrap() 
+int yywrap()
 {
 	return 1;
 }