Merge pull request #34 from mattfenwick/master

Parser:  grammar, top-level parsing, terminology
This commit is contained in:
Paul Tagliamonte 2013-01-27 16:44:39 -08:00
commit bfef42cc66
2 changed files with 52 additions and 0 deletions

47
grammar.md Normal file
View 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

View File

@ -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"')