Added commas to parser
Getty Ritter
8 years ago
49 | 49 |
\) { lex' TkRParn }
|
50 | 50 |
\: { lex' TkColon }
|
51 | 51 |
\; { lex' TkSemi }
|
| 52 |
\, { lex' TkComma }
|
52 | 53 |
|
53 | 54 |
{
|
54 | 55 |
data Token = Token AlexPosn TkType deriving (Eq, Show)
|
|
73 | 74 |
| TkRBrac
|
74 | 75 |
| TkLParn
|
75 | 76 |
| TkRParn
|
| 77 |
| TkComma
|
76 | 78 |
| TkEOF
|
77 | 79 |
deriving (Eq, Show)
|
78 | 80 |
|
21 | 21 |
']' { Token _ TkRBrac }
|
22 | 22 |
':' { Token _ TkColon }
|
23 | 23 |
';' { Token _ TkSemi }
|
| 24 |
',' { Token _ TkComma }
|
24 | 25 |
|
25 | 26 |
with { Token _ (TkKw KwWith) }
|
26 | 27 |
true { Token _ (TkKw KwTrue) }
|
|
37 | 38 |
: '[' list { mkArray $2 }
|
38 | 39 |
| '{' dict { mkObject $2 }
|
39 | 40 |
|
40 | |
expr
|
41 | |
: tlexpr { $1 }
|
42 | |
| int { ChNumber (fromIntegral $1) }
|
| 41 |
scalar
|
| 42 |
: int { ChNumber (fromIntegral $1) }
|
43 | 43 |
| float { ChNumber $1 }
|
44 | 44 |
| str { ChString $1 }
|
45 | 45 |
| true { ChBool True }
|
46 | 46 |
| false { ChBool False}
|
47 | 47 |
| null { ChNull }
|
48 | 48 |
|
| 49 |
expr
|
| 50 |
: tlexpr { $1 }
|
| 51 |
| scalar { $1 }
|
| 52 |
|
49 | 53 |
list
|
50 | |
: ']' { [] }
|
51 | |
| expr list { $1 : $2 }
|
| 54 |
: ']' { [] }
|
| 55 |
| expr ']' { [ $1 ] }
|
| 56 |
| expr ',' list { $1 : $3 }
|
52 | 57 |
|
53 | 58 |
dict
|
54 | 59 |
: '}' { [] }
|
55 | |
| str ':' expr dict { ($1, $3) : $4 }
|
| 60 |
| str ':' expr '}' { [ ($1, $3) ] }
|
| 61 |
| str ':' expr ',' dict { ($1, $3) : $5 }
|
56 | 62 |
|
57 | 63 |
{
|
58 | 64 |
|