Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. line    :   push identifier ent                 {pushStack($2);}
  2.         |   line push identifier ent            {pushStack($3);}
  3.         |   pop identifier ent                  {popStack($2);}
  4.         |   line pop identifier ent             {popStack($3);}
  5.         |   exit_command ent                    {exit(EXIT_SUCCESS);}
  6.         |   show identifier ent                 {showVal($2);}
  7.         |   line show identifier ent            {showVal($3);}
  8.         |   load identifier identifier ent      {loadVal($2,$3);}
  9.         |   line load identifier identifier ent {loadVal($3,$4);}
  10.         |   line exit_command ent               {exit(EXIT_SUCCESS);}
  11.         |   line exp ent                        {$$ = $2; getError($$);}
  12.         |   exp ent                             {$$ = $1; getError($$);}
  13.         |   '-' '-' exp ent                     {printf("ERROR !\n");}
  14.         |   line '-' '-' exp ent                {printf("ERROR !\n");}
  15.         ;
  16.  
  17. exp     :   term            {$$ = $1;}
  18.         |   '+' exp         {checkError();}
  19.         |   '*' exp         {checkError();}
  20.         |   '/' exp         {checkError();}
  21.         |   exp and exp     {$$ = $1 & $3;}
  22.         |   exp or exp      {$$ = $1 | $3;}
  23.         |   exp '+' exp     {$$ = $1 + $3;}
  24.         |   exp '-' exp     {$$ = $1 - $3;}
  25.         |   exp '*' exp     {$$ = $1 * $3;}
  26.         |   exp '/' exp     {$$ = $1 / $3;}
  27.         |   exp '\\' exp    {$$ = $1 % $3;}
  28.         |   exp '^' exp     {$$ = pow($1,$3);}
  29.         |   '-' exp         {$$ = $2*-1;}
  30.         |   not exp         {$$ = !$2;}
  31.         |   '(' exp ')'     {$$ = $2;}
  32.         ;
  33.  
  34. term    :   number      {$$ = $1;}
  35.         |   identifier  {$$ = symbolVal($1);}
  36.         ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement