From 659af492314189c28c53ded01829f469430ecb94 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 30 Nov 2017 17:44:06 +0100 Subject: [PATCH] Clean up grammar (#268) --- GRAMMAR.md | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/GRAMMAR.md b/GRAMMAR.md index 9fa3bea..e84cb18 100644 --- a/GRAMMAR.md +++ b/GRAMMAR.md @@ -10,21 +10,28 @@ tokens ------ ``` -BACKTICK = `[^`\n\r]*` -COLON = : -COMMENT = #([^!].*)?$ -NEWLINE = \n|\r\n -EQUALS = = -INTERPOLATION_START = {{ -INTERPOLATION_END = }} -NAME = [a-zA-Z_][a-zA-Z0-9_-]* -PLUS = + -RAW_STRING = '[^'\r\n]*' -STRING = "[^"]*" # also processes \n \r \t \" \\ escapes -INDENT = emitted when indentation increases -DEDENT = emitted when indentation decreases -LINE = emitted before a recipe line -TEXT = recipe text, only matches in a recipe body +BACKTICK = `[^`\n\r]*` +COMMENT = #([^!].*)?$ +DEDENT = emitted when indentation decreases +EOF = emitted at the end of the file +INDENT = emitted when indentation increases +LINE = emitted before a recipe line +NAME = [a-zA-Z_][a-zA-Z0-9_-]* +NEWLINE = \n|\r\n +RAW_STRING = '[^'\r\n]*' +STRING = "[^"]*" # also processes \n \r \t \" \\ escapes +TEXT = recipe text, only matches in a recipe body +``` + +grammar syntax +-------------- + +``` +| alternation +() grouping +_? option (0 or 1 times) +_* repetition (0 or more times) +_+ repetition (1 or more times) ``` grammar @@ -45,11 +52,13 @@ assignment : NAME '=' expression eol export : 'export' assignment -expression : STRING +expression : value '+' expression + | value + +value : STRING | RAW_STRING | NAME | BACKTICK - | expression '+' expression recipe : '@'? NAME parameter* ('+' parameter)? ':' dependencies? body?