Merge pull request #34 from mattfenwick/master
Parser: grammar, top-level parsing, terminology
This commit is contained in:
commit
bfef42cc66
47
grammar.md
Normal file
47
grammar.md
Normal file
@ -0,0 +1,47 @@
|
||||
## Lexical syntax ##
|
||||
|
||||
OPEN-PAREN := '('
|
||||
|
||||
CLOSE-PAREN := ')'
|
||||
|
||||
OPEN-SQUARE := '['
|
||||
|
||||
CLOSE-SQUARE := ']'
|
||||
|
||||
OPEN-CURLY := '{'
|
||||
|
||||
CLOSE-CURLY := '}'
|
||||
|
||||
WHITESPACE := ' ' | '\t' | '\n' | '\r'
|
||||
|
||||
COMMENT := ';' ???
|
||||
|
||||
STRING := '"' ??? '"'
|
||||
|
||||
CONSTANT := '*' ??? '*'
|
||||
|
||||
BOOLEAN := 'true' | 'false'
|
||||
|
||||
SYMBOL := ???
|
||||
|
||||
NUMBER := ???
|
||||
|
||||
HASH := '#!' ???
|
||||
|
||||
|
||||
## Grammar ## ([example](http://docs.python.org/2/reference/grammar.html))
|
||||
|
||||
Hy := HASH | COMMENT | WHITESPACE | Expression
|
||||
|
||||
Expression := OPEN-PAREN Operator Args Close-Paren
|
||||
|
||||
Operator := ???
|
||||
|
||||
Args := Value(*)
|
||||
|
||||
List := OPEN-SQUARE Value(*) CLOSE-SQUARE
|
||||
|
||||
Map := OPEN-CURLY ( Value Value )(*) CLOSE-CURLY
|
||||
|
||||
Value := STRING | CONSTANT | BOOLEAN | SYMBOL | NUMBER | Expression | List | Map
|
||||
|
@ -73,3 +73,8 @@ def test_full_recurse():
|
||||
],
|
||||
['fn1', 'foo', 'bar']
|
||||
] == tokenize("(fn el (+ 1 2 (== 1 20) (- 1 1)))(fn1 foo bar)")
|
||||
|
||||
|
||||
def test_string():
|
||||
""" Lex a lone string """
|
||||
assert ['"a string"'] == tokenize('"a string"')
|
||||
|
Loading…
Reference in New Issue
Block a user