OLD | NEW |
1 part of lisp; | 1 part of petitparser.lisp; |
2 | 2 |
3 /** | 3 /// LISP parser. |
4 * LISP parser. | |
5 */ | |
6 class LispParser extends GrammarParser { | 4 class LispParser extends GrammarParser { |
7 LispParser() : super(new LispParserDefinition()); | 5 LispParser() : super(new LispParserDefinition()); |
8 } | 6 } |
9 | 7 |
10 /** | 8 /// LISP parser definition. |
11 * LISP parser definition. | |
12 */ | |
13 class LispParserDefinition extends LispGrammarDefinition { | 9 class LispParserDefinition extends LispGrammarDefinition { |
14 | 10 |
15 list() => super.list().map((each) => each[1]); | 11 list() => super.list().map((each) => each[1]); |
16 | 12 |
17 cell() => super.cell().map((each) => new Cons(each[0], each[1])); | 13 cell() => super.cell().map((each) => new Cons(each[0], each[1])); |
18 empty() => super.empty().map((each) => null); | 14 empty() => super.empty().map((each) => null); |
19 | 15 |
20 string() => super.string().map((each) => new String.fromCharCodes(each[1])); | 16 string() => super.string().map((each) => new String.fromCharCodes(each[1])); |
21 characterEscape() => super.characterEscape().map((each) => each[1].codeUnitAt(
0)); | 17 characterEscape() => super.characterEscape().map((each) => each[1].codeUnitAt(
0)); |
22 characterRaw() => super.characterRaw().map((each) => each.codeUnitAt(0)); | 18 characterRaw() => super.characterRaw().map((each) => each.codeUnitAt(0)); |
23 | 19 |
24 symbol() => super.symbol().map((each) => new Name(each)); | 20 symbol() => super.symbol().map((each) => new Name(each)); |
25 number() => super.number().map((each) { | 21 number() => super.number().map((each) { |
26 var floating = double.parse(each); | 22 var floating = double.parse(each); |
27 var integral = floating.toInt(); | 23 var integral = floating.toInt(); |
28 if (floating == integral && each.indexOf('.') == -1) { | 24 if (floating == integral && each.indexOf('.') == -1) { |
29 return integral; | 25 return integral; |
30 } else { | 26 } else { |
31 return floating; | 27 return floating; |
32 } | 28 } |
33 }); | 29 }); |
34 | 30 |
35 quote() => super.quote().map((each) => new Cons(Natives._quote, each[1])); | 31 quote() => super.quote().map((each) => new Cons(Natives._quote, each[1])); |
36 | 32 |
37 } | 33 } |
OLD | NEW |