Skip to content

Instantly share code, notes, and snippets.

@hlindberg
Created February 14, 2020 08:55
Show Gist options
  • Save hlindberg/f755dd5b532b511aa97580f4d6d6b2f4 to your computer and use it in GitHub Desktop.
Save hlindberg/f755dd5b532b511aa97580f4d6d6b2f4 to your computer and use it in GitHub Desktop.
# Puppet EBNF (kind of)
# Try with: http://www.bottlecaps.de/rr/ui
ACTOR ::= 'actor' ( '(' PARAMS ')')? ('inherits' NAME)?
'{'
(QUEUE | INBOX | ACTION | SEQUENCE | PARALLEL | FUNCTION | STATE | CONSTANT | LOCAL_TYPE)*
'}'
SEQUENCE ::= 'sequence' '{' (ACTION | SEQUENCE | PARALLEL)* '}'
PARALLEL ::= 'parallel' '{' (ACTION | SEQUENCE | PARALLEL)* '}'
ACTION ::= 'action' NAME ('{' INPUT* OUTPUT* '}')?
INPUT ::= ('!!' ASSIGNMENTS? | ASSIGNMENTS ) '<-' (EXPRESSION | 'state') ('where' EXPRESSION)?
ASSIGNMENTS ::= VARIABLE | '_' | '[' ASSIGNMENTS (',' ASSIGNMENTS)* ','? ']' | '(' ASSIGNMENTS (',' ASSIGNMENTS)* ','? ')'
FUNCTION ::= 'function' '(' PARAMS ')' '{' EXPRESSION* '}'
STATE ::= WORD ( ',' WORD)*
QUEUE ::= VISIBILITY 'queue' TYPE NAME ('{' ( (
'capacity'
| 'ttl'
| 'entries'
| 'schedule'
| 'latched'
| 'replace'
)
'=>' EXPRESSION)* '}')?
INBOX ::= VISIBILITY 'queue' TYPE NAME ('{' ( (
'capacity'
| 'ttl'
| 'entries'
| 'schedule'
| 'latched'
| 'replace'
)
'=>' EXPRESSION)* '}')?
PARAMS ::= TYPE? '*'? VARIABLE ('=' EXPRESSION)? (',' TYPE? '*'? VARIABLE ('=' EXPRESSION)?)* ','?
CONSTANT ::= VARIABLE '=' EXPRESSION
LOCAL_TYPE ::= 'type' TYPE_NAME '=' TYPE_EXPRESSION
VARIABLE ::= '$' NAME
NAME ::= [a-z][a-z0-9A-Z]*
IGNORED ::= [_]
VISIBILITY ::= 'private' | 'protected' | 'public'
EXPRESSION ::= EXPRESSION ('+' | '-' | '*' | '/' | '%' | '.' | 'and' | 'or' | '==' | '!=' | '=~' | '!~' | '<' | '>' | '>=' | '<=' ) EXPRESSION
| EXPRESSION '[' EXPRESSION (',' EXPRESSION)* ','?']'
| '-' EXPRESSION
| '(' EXPRESSION ')'
| 'not' EXPRESSION
| 'if' EXPRESSION '{' EXPRESSIONS? '}' ELSE_IF* ELSE?
| 'unless' EXPRESSION '{' EXPRESSIONS? '}' ELSE?
| 'case' EXPRESSION '{' ((EXPRESSION (',' EXPRESSION)*) ':' '{' EXPRESSIONS? '}' )* '}'
| EXPRESSION '?' '{' (EXPRESSION '=>' EXPRESSION (',' EXPRESSION '=>' EXPRESSION)* ) '}'
| 'default' | 'undef'
| DQ_STRING | HEREDOC
| LITERAL
LITERAL ::= INTEGER | FLOAT | SQ_STRING | BOOLEAN | REGEXP
BOOLEAN ::= 'false' | 'true'
INTEGER ::= '0' [0-7]* | ('0x' | '0X') [0-9a-fA-F]* | [1-9][0-9]*
FLOAT ::= [0-9]+ '.' [0-9]+ (('e'|'E') ('+'|'-') [0-9]+)
SQ_STRING ::= ['] '<chars and escapes>' [']
DQ_STRING ::= ["] '<chars, escapes, and interpolation>' ["]
HEREDOC ::= '@(' '<heredoc-header-syntax>' ')'
REGEXP ::= '/' '<regexp-syntax>' '/'
EXPRESSIONS ::= EXPRESSION (';'? EXPRESSION)*
ELSIF ::= 'elsif' EXPRESSION '{' EXPRESSIONS? '}'
ELSE ::= 'else' '{' EXPRESSIONS? '}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment