Menu

[r10]: / trunk / lime / examples / calc.lime  Maximize  Restore  History

Download this file

25 lines (18 with data), 361 Bytes

%class calc
%start stmt

%left '+' '-'
%left '*' '/'

stmt = exp { echo " -> "; echo $1; echo "\n"; }
| var/v '=' exp/e {
	echo "$v = $e\n";
	set_variable($v, $e);
}
.


exp = num
| var { $$ = get_variable($1); }
| exp '+' exp { $$ = $1 + $3; }
| exp '-' exp { $$ = $1 - $3; }
| exp '*' exp { $$ = $1 * $3; }
| exp '/' exp { $$ = $1 / $3; }
| '(' exp/$ ')'
.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.