Cleanup success

This commit is contained in:
Daniel Flanagan 2019-11-19 22:28:05 -06:00
parent 58f9f43896
commit ed602ab3f3

View file

@ -1,22 +1,16 @@
Nonterminals
grammar
expr_list
expr
assign_expr
add_expr
sub_expr
mult_expr
div_expr
idiv_expr
unary_expr
max_expr
e_list
e
assignment
add
sub
mult
div
idiv
unary
number
unary_op
add_op
sub_op
mult_op
div_op
idiv_op
unary
.
Terminals
@ -34,65 +28,53 @@ Left 400 '*'.
Left 400 '/'.
Left 400 '//'.
grammar -> expr_list : '$1'.
grammar -> e_list : '$1'.
grammar -> '$empty' : [].
expr_list -> eol : [].
expr_list -> expr : ['$1'].
expr_list -> expr eol : ['$1'].
expr_list -> eol expr_list : '$2'.
expr_list -> expr eol expr_list : ['$1'|'$3'].
e_list -> eol : [].
e_list -> e : ['$1'].
e_list -> e eol : ['$1'].
e_list -> eol e_list : '$2'.
e_list -> e eol e_list : ['$1'|'$3'].
%% Minimum expressions
max_expr -> var : '$1'.
max_expr -> number : '$1'.
max_expr -> '(' expr ')' : '$2'.
e -> var : '$1'.
e -> number : '$1'.
e -> '(' e ')' : '$2'.
%% Numbers
number -> float : '$1'.
number -> integer : ?e(3, '$1').
%% Unary operator
unary_op -> '+' : '$1'.
unary_op -> '-' : '$1'.
e -> mult : '$1'.
e -> div : '$1'.
e -> idiv : '$1'.
e -> assignment : '$1'.
e -> add : '$1'.
e -> sub : '$1'.
e -> unary : '$1'.
%% Infix Operators
add_op -> '+' : '$1'.
sub_op -> '-' : '$1'.
mult_op -> '*' : '$1'.
div_op -> '/' : '$1'.
idiv_op -> '//' : '$1'.
expr -> mult_expr : '$1'.
expr -> div_expr : '$1'.
expr -> idiv_expr : '$1'.
expr -> assign_expr : '$1'.
expr -> add_expr : '$1'.
expr -> sub_expr : '$1'.
expr -> unary_expr : '$1'.
expr -> max_expr : '$1'.
assign_expr -> var '=' expr :
assignment -> var '=' e :
{ '=', ?meta('$2'), [?var('$1'), '$3'] }.
%% Arithmetic operations
add_expr -> expr add_op expr :
add -> e '+' e :
{ '+', ?meta('$2'), ['$1', '$3'] }.
sub_expr -> expr sub_op expr :
sub -> e '-' e :
{ '-', ?meta('$2'), ['$1', '$3'] }.
mult_expr -> expr mult_op expr :
mult -> e '*' e :
{ '*', ?meta('$2'), ['$1', '$3'] }.
div_expr -> expr div_op expr :
div -> e '/' e :
{ '/', ?meta('$2'), ['$1', '$3'] }.
idiv_expr -> expr idiv_op expr :
idiv -> e '//' e :
{ 'div', ?meta('$2'), ['$1', '$3'] }.
unary_expr -> unary_op expr :
{ unary_op, ?meta('$1'), ?op('$1'), '$2' }.
unary -> '+' e : { '+', ?meta('$1'), ?op('$1'), '$2' }.
unary -> '-' e : { '-', ?meta('$1'), ?op('$1'), '$2' }.
Erlang code.