Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Side by Side Diff: petitparser/lib/src/lisp/grammar.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « petitparser/lib/src/lisp/environment.dart ('k') | petitparser/lib/src/lisp/name.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 part of lisp;
2
3 /**
4 * LISP grammar.
5 */
6 class LispGrammar extends GrammarParser {
7 LispGrammar() : super(new LispGrammarDefinition());
8 }
9
10 /**
11 * LISP grammar definition.
12 */
13 class LispGrammarDefinition extends GrammarDefinition {
14
15 start() => ref(atom).star().end();
16
17 atom() => ref(atom_).trim(ref(space));
18 atom_() => ref(list)
19 | ref(number)
20 | ref(string)
21 | ref(symbol)
22 | ref(quote)
23 | ref(quasiquote)
24 | ref(unquote)
25 | ref(splice);
26
27 list() => ref(bracket, '()', ref(cells))
28 | ref(bracket, '[]', ref(cells))
29 | ref(bracket, '{}', ref(cells));
30 cells() => ref(cell)
31 | ref(empty);
32 cell() => ref(atom) & ref(cells);
33 empty() => ref(space).star();
34
35 number() => ref(number_).flatten();
36 number_() => anyIn('-+').optional()
37 & char('0').or(digit().plus())
38 & char('.').seq(digit().plus()).optional()
39 & anyIn('eE').seq(anyIn('-+').optional()).seq(digit().plus()).optional();
40
41 string() => ref(bracket, '""', ref(character).star());
42 character() => ref(characterEscape) | ref(characterRaw);
43 characterEscape() => char('\\') & any();
44 characterRaw() => pattern('^"');
45
46 symbol() => ref(symbol_).flatten();
47 symbol_() => pattern('a-zA-Z!#\$%&*/:<=>?@\\^_|~+-')
48 & pattern('a-zA-Z0-9!#\$%&*/:<=>?@\\^_|~+-').star();
49
50 quote() => char('\'') & ref(list);
51 quasiquote() => char('`') & ref(list);
52 unquote() => char(',') & ref(list);
53 splice() => char('@') & ref(list);
54
55 space() => whitespace() | ref(comment);
56 comment() => char(';') & Token.newlineParser().neg().star();
57 bracket(String brackets, Parser parser) => char(brackets[0]) & parser & char(b rackets[1]);
58
59 }
OLDNEW
« no previous file with comments | « petitparser/lib/src/lisp/environment.dart ('k') | petitparser/lib/src/lisp/name.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698