Generated from spec/preprocessor.y by spec/tools/grammar_diagrams.py; do not edit.
Diagrams read left to right; a track that turns back is a repetition.
program ::= program_body
program
: program_body
;program_body ::= statements+
program_body
: program_body statements
| statements
| program_body statements error
| statements error
;statements
::= 'WORD'
| 'MACROWORD' '(' macro_expand_parameters ')'
| 'MACRO' macro_name '{' macro_define_parameters '}' macro_body 'ENDM'
| 'PARAM'
| 'DEFAULT' 'PARAM' expand_words 'end of line'
| equate_definition
| if_cond
| ifdef_cond
| ifndef_cond
| include_options
| jppfilename
| 'JPPECHO'
| 'DEFINE' 'WORD' word_list 'end of line'statements
: WORD
| MACROWORD {} '(' {} macro_expand_parameters ')'
| MACRO {} macro_name {} '{' macro_define_parameters '}' {} macro_body ENDM
| PARAM
| DEFAULT PARAM {} expand_words EOL
| equate_definition
| if_cond
| ifdef_cond
| ifndef_cond
| include_options
| jppfilename
| JPPECHO
| error
| DEFINE WORD {} word_list EOL
;macro_expand_parameters ::= expand_words? ( ',' expand_words? )*macro_expand_parameters
: macro_expand_parameters ',' {} expand_param
| expand_param
;macro_name ::= 'WORD'+macro_name
: macro_name WORD
| WORD
;macro_define_parameters ::= 'PARAM' ( ',' 'PARAM' )*
macro_define_parameters
: macro_define_parameters ',' PARAM
| PARAM
;macro_body ::= program_body
macro_body
: program_body
;expand_words ::= 'WORD'+expand_words
: expand_words WORD
| WORD
;equate_definition ::= 'EQUATE' equate_list ( 'end of line' | ';' )
equate_definition
: EQUATE {} equate_list equate_end
;if_cond ::= 'IF' expression program_body ( 'ELSE' program_body? )? 'ENDIF'
if_cond
: IF {} expression {} program_body opt_else ENDIF
;ifdef_cond ::= 'IFDEF' ( 'WORD' | 'PARAM' ) program_body? ( 'ELSE' program_body? )? 'ENDIF'
ifdef_cond
: IFDEF def_target {} cond_body opt_else ENDIF
;ifndef_cond ::= 'IFNDEF' ( 'WORD' | 'PARAM' ) program_body? ( 'ELSE' program_body? )? 'ENDIF'
ifndef_cond
: IFNDEF def_target {} cond_body opt_else ENDIF
;include_options ::= 'INCLUDE' include_words 'end of line'
include_options
: INCLUDE {} include_words EOL
;jppfilename ::= 'JPPFILENAME' 'WORD' 'WORD' 'end of line'
jppfilename
: JPPFILENAME {} WORD WORD EOL
;word_list ::= 'WORD'+word_list
: word_list WORD
| WORD
;equate_list ::= 'WORD' ( 'TO' | 'LIT' ) word_list ( ',' 'WORD' ( 'TO' | 'LIT' ) word_list )*
equate_list
: equate_list ',' WORD {} to_or_lit {} word_list
| WORD {} to_or_lit {} word_list
;expression
::= ( '!' expression
| '(' expression ')'
| ( 'WORD' | 'PARAM' ) ( '=' | '#' | '>' | '<' ) ( 'WORD' | 'PARAM' )
) ( ( 'AND' | '&' | 'OR' | '|' ) expression )*expression
: expression AND expression
| expression '&' expression
| expression OR expression
| expression '|' expression
| '!' expression
| '(' expression ')'
| comp_word '=' comp_word
| comp_word '#' comp_word
| comp_word '>' comp_word
| comp_word '<' comp_word
;include_words ::= 'WORD'+include_words
: include_words WORD
| WORD
;| Binds | Associativity | Tokens |
|---|---|---|
| 1 | left | < > |
| 2 | left | # = |
| 3 | left | AND |
| 4 | left | OR |