gdritter repos virgil / ac2aa42
Added commas to parser Getty Ritter 8 years ago
2 changed file(s) with 14 addition(s) and 6 deletion(s). Collapse all Expand all
4949 \) { lex' TkRParn }
5050 \: { lex' TkColon }
5151 \; { lex' TkSemi }
52 \, { lex' TkComma }
5253
5354 {
5455 data Token = Token AlexPosn TkType deriving (Eq, Show)
7374 | TkRBrac
7475 | TkLParn
7576 | TkRParn
77 | TkComma
7678 | TkEOF
7779 deriving (Eq, Show)
7880
2121 ']' { Token _ TkRBrac }
2222 ':' { Token _ TkColon }
2323 ';' { Token _ TkSemi }
24 ',' { Token _ TkComma }
2425
2526 with { Token _ (TkKw KwWith) }
2627 true { Token _ (TkKw KwTrue) }
3738 : '[' list { mkArray $2 }
3839 | '{' dict { mkObject $2 }
3940
40 expr
41 : tlexpr { $1 }
42 | int { ChNumber (fromIntegral $1) }
41 scalar
42 : int { ChNumber (fromIntegral $1) }
4343 | float { ChNumber $1 }
4444 | str { ChString $1 }
4545 | true { ChBool True }
4646 | false { ChBool False}
4747 | null { ChNull }
4848
49 expr
50 : tlexpr { $1 }
51 | scalar { $1 }
52
4953 list
50 : ']' { [] }
51 | expr list { $1 : $2 }
54 : ']' { [] }
55 | expr ']' { [ $1 ] }
56 | expr ',' list { $1 : $3 }
5257
5358 dict
5459 : '}' { [] }
55 | str ':' expr dict { ($1, $3) : $4 }
60 | str ':' expr '}' { [ ($1, $3) ] }
61 | str ':' expr ',' dict { ($1, $3) : $5 }
5662
5763 {
5864