Modify tokenizer to parse notes
This commit is contained in:
74
grammar
74
grammar
@@ -1,42 +1,42 @@
|
||||
integer := ...
|
||||
string := ...
|
||||
note := ...
|
||||
identifier := ...
|
||||
# Tokenizer
|
||||
DIGIT = [0-9]
|
||||
ID = [a-zA-Z_]
|
||||
CHAR = ... \ '"'
|
||||
PITCH = 'c' | 'd' | 'e' | 'f' | 'g' | 'a' | 'h'
|
||||
PITCH_MODIFIER = 'b' | '#'
|
||||
|
||||
expr := integer
|
||||
expr := string
|
||||
expr := note
|
||||
expr := identifier
|
||||
expr := access
|
||||
expr := assignment
|
||||
expr := functionCall
|
||||
integer := '-' DIGIT+ | DIGIT+
|
||||
string := '"' CHAR* '"'
|
||||
note := '@' PITCH PITCH_MODIFIER? DIGIT? ['.' DIGIT+ 'd'?]?
|
||||
identifier := ID [ID|DIGIT]*
|
||||
percent := DIGIT+ '%'
|
||||
|
||||
# left associative
|
||||
access := expr '.' expr
|
||||
|
||||
# right associative
|
||||
asterisk := expr '*' stmt
|
||||
|
||||
stmt := asterisk
|
||||
stmt := block
|
||||
stmt := return
|
||||
stmt := functionDefinition
|
||||
|
||||
# right associative
|
||||
assignment := identifier '=' expr
|
||||
|
||||
list := '(' ')'
|
||||
list := '(' expr listTail
|
||||
|
||||
listTail := expr ', ' listTail
|
||||
listTail := ')'
|
||||
|
||||
percent := integer '%'
|
||||
|
||||
return := 'return' expr
|
||||
|
||||
block := '{' stmt* '}'
|
||||
# Parser
|
||||
expr := integer accessTail | integer
|
||||
expr := percent accessTail | percent
|
||||
expr := string accessTail | string
|
||||
expr := note accessTail | note
|
||||
expr := identifier accessTail | identifier '=' expr | functionCall | identifier
|
||||
expr := list accessTail | list
|
||||
expr := functionCall accessTail | functionCall
|
||||
|
||||
functionCall := identifier list
|
||||
|
||||
functionDefinition := 'function' identifier list block
|
||||
accessTail := '.' expr accessTail | e
|
||||
|
||||
list := '[' ']' | '[' expr listTail
|
||||
listTail := expr ', ' listTail | ']'
|
||||
|
||||
argList := '(' ')' | '(' expr argListTail
|
||||
argListTail := expr ', ' argListTail | ')'
|
||||
|
||||
block := '{' stmt* '}'
|
||||
|
||||
stmt := expr asteriskTail | expr #nie wiem czy zamiast 'expr asteriskTail' nie powinno być wprost co może wyprodukować iterator dla asterisk
|
||||
asteriskTail := '*' stmt | e
|
||||
stmt := block
|
||||
stmt := 'return' expr
|
||||
stmt := 'function' identifier list block
|
||||
|
||||
program := stmt*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user