mirror of
https://github.com/sigmasternchen/libparcival
synced 2025-03-15 03:48:55 +00:00
basic parser
This commit is contained in:
parent
c592ef5369
commit
8b15908418
1 changed files with 49 additions and 0 deletions
49
src/parser.y
Normal file
49
src/parser.y
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
%token SECTION TEXT COMMA END
|
||||
%token PARAMS_BEGIN PARAMS_END
|
||||
%token STATEMENT_BEGIN STATEMENT_END
|
||||
%token OUTPUT_BEGIN OUTPUT_END
|
||||
|
||||
%start file
|
||||
|
||||
%%
|
||||
|
||||
file: metaSection SECTION mainSection
|
||||
;
|
||||
|
||||
metaSection: PARAMS_BEGIN parameters PARAMS_END
|
||||
| STATEMENT_BEGIN metaStatement STATEMENT_END
|
||||
;
|
||||
|
||||
parameters: /* empty */
|
||||
| parameter moreParameters
|
||||
;
|
||||
|
||||
parameter: /* empty */
|
||||
| TEXT parameter
|
||||
;
|
||||
|
||||
moreParameters: /* empty */
|
||||
| COMMA /* allow trailing commas */
|
||||
| COMMA parameter moreParameters
|
||||
;
|
||||
|
||||
metaStatement: statement
|
||||
;
|
||||
|
||||
mainSection: /* empty */
|
||||
| TEXT mainSection
|
||||
| STATEMENT_BEGIN blockStatement STATEMENT_END mainSection
|
||||
| OUTPUT_BEGIN output OUTPUT_END mainSection
|
||||
;
|
||||
|
||||
blockStatement: statement
|
||||
;
|
||||
|
||||
statement: TEXT /* statement can't be empty */
|
||||
| TEXT statement
|
||||
;
|
||||
|
||||
output: TEXT /* output can't be empty */
|
||||
| TEXT output
|
||||
;
|
Loading…
Reference in a new issue