Clean up grammar (#268)

This commit is contained in:
Casey Rodarmor 2017-11-30 17:44:06 +01:00 committed by GitHub
parent def1bda9ff
commit 659af49231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,21 +10,28 @@ tokens
------ ------
``` ```
BACKTICK = `[^`\n\r]*` BACKTICK = `[^`\n\r]*`
COLON = : COMMENT = #([^!].*)?$
COMMENT = #([^!].*)?$ DEDENT = emitted when indentation decreases
NEWLINE = \n|\r\n EOF = emitted at the end of the file
EQUALS = = INDENT = emitted when indentation increases
INTERPOLATION_START = {{ LINE = emitted before a recipe line
INTERPOLATION_END = }} NAME = [a-zA-Z_][a-zA-Z0-9_-]*
NAME = [a-zA-Z_][a-zA-Z0-9_-]* NEWLINE = \n|\r\n
PLUS = + RAW_STRING = '[^'\r\n]*'
RAW_STRING = '[^'\r\n]*' STRING = "[^"]*" # also processes \n \r \t \" \\ escapes
STRING = "[^"]*" # also processes \n \r \t \" \\ escapes TEXT = recipe text, only matches in a recipe body
INDENT = emitted when indentation increases ```
DEDENT = emitted when indentation decreases
LINE = emitted before a recipe line grammar syntax
TEXT = recipe text, only matches in a recipe body --------------
```
| alternation
() grouping
_? option (0 or 1 times)
_* repetition (0 or more times)
_+ repetition (1 or more times)
``` ```
grammar grammar
@ -45,11 +52,13 @@ assignment : NAME '=' expression eol
export : 'export' assignment export : 'export' assignment
expression : STRING expression : value '+' expression
| value
value : STRING
| RAW_STRING | RAW_STRING
| NAME | NAME
| BACKTICK | BACKTICK
| expression '+' expression
recipe : '@'? NAME parameter* ('+' parameter)? ':' dependencies? body? recipe : '@'? NAME parameter* ('+' parameter)? ':' dependencies? body?