aboutsummaryrefslogtreecommitdiff
path: root/src/parser.y
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-10-20 23:08:40 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-10-23 18:25:23 +0300
commiteaa9f2c6dd47c7267c4e7f25565f8cf7f390e114 (patch)
treea7edbd5fd965e562dfb76aeda9ed82c9b8a3eb03 /src/parser.y
parent55428637a8536764a82693c19d76e61a6f557627 (diff)
downloadlyn-eaa9f2c6dd47c7267c4e7f25565f8cf7f390e114.tar.gz
lyn-eaa9f2c6dd47c7267c4e7f25565f8cf7f390e114.zip
rename parser states to be less silly
Diffstat (limited to 'src/parser.y')
-rw-r--r--src/parser.y33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/parser.y b/src/parser.y
index edf71c1..2cf2a84 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -48,8 +48,8 @@
%token BACKSLASH "\\"
%token NL "nl"
-%nterm <ast> arg args rev_args
-%nterm <ast> cmd cmds rev_cmds
+%nterm <ast> arg args
+%nterm <ast> cmd cmds cmd_list
%{
@@ -95,8 +95,8 @@ static void yyerror(YYLTYPE *yylloc, void *lexer,
%%
arg
- : "(" cmds ")" {$$ = $2; $$.kind = LYN_APPLY;}
- | "{" cmds "}" {$$ = $2; $$.kind = LYN_GROUP;}
+ : "(" cmd_list ")" {$$ = $2; $$.kind = LYN_APPLY;}
+ | "{" cmd_list "}" {$$ = $2; $$.kind = LYN_GROUP;}
| ID {$$ = gen_id($1);}
| STRING {$$ = gen_str($1);}
| INT {$$ = gen_int($1);}
@@ -105,13 +105,10 @@ arg
cont
: BACKSLASH NL
-rev_args
- : rev_args cont arg {$$ = $1; vect_append(struct lyn_value, $$.args, &$3);}
- | rev_args arg {$$ = $1; vect_append(struct lyn_value, $$.args, &$2);}
- | arg {$$ = gen_list(); vect_append(struct lyn_value, $$.args, &$1);}
-
args
- : rev_args
+ : args cont arg {$$ = $1; vect_append(struct lyn_value, $$.args, &$3);}
+ | args arg {$$ = $1; vect_append(struct lyn_value, $$.args, &$2);}
+ | arg {$$ = gen_list(); vect_append(struct lyn_value, $$.args, &$1);}
sep
: sep ";"
@@ -122,19 +119,19 @@ sep
cmd
: args {$$ = $1; $$.kind = LYN_CMD;}
-rev_cmds
- : rev_cmds sep cmd {$$ = $1; vect_append(struct lyn_value, $$.args, &$3);}
+cmds
+ : cmds sep cmd {$$ = $1; vect_append(struct lyn_value, $$.args, &$3);}
| cmd {$$ = gen_list(); vect_append(struct lyn_value, $$.args, &$1);}
-cmds
- : rev_cmds
- | rev_cmds sep
- | sep rev_cmds {$$ = $2;}
- | sep rev_cmds sep {$$ = $2;}
+cmd_list
+ : cmds
+ | cmds sep
+ | sep cmds {$$ = $2;}
+ | sep cmds sep {$$ = $2;}
| {$$ = gen_list();}
input
- : cmds {$1.kind = LYN_GROUP; parser->tree = $1;}
+ : cmd_list {$1.kind = LYN_GROUP; parser->tree = $1;}
| error {parser->failed = true;}
%%