OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #library("peg_tests"); | 5 #library("peg_tests"); |
6 #import('../../peg/pegparser.dart'); | 6 #import('../../peg/pegparser.dart'); |
7 | 7 |
8 testParens() { | 8 testParens() { |
9 Grammar g = new Grammar(); | 9 Grammar g = new Grammar(); |
10 Symbol a = g['A']; | 10 Symbol a = g['A']; |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 var a = MANY(TEXT('x')); | 37 var a = MANY(TEXT('x')); |
38 | 38 |
39 g.whitespace = OR([g.whitespace, blockComment]); | 39 g.whitespace = OR([g.whitespace, blockComment]); |
40 | 40 |
41 check(g, a, "x /**/ x", '[x,x]'); | 41 check(g, a, "x /**/ x", '[x,x]'); |
42 check(g, a, "x /*/**/*/ x", '[x,x]'); | 42 check(g, a, "x /*/**/*/ x", '[x,x]'); |
43 check(g, a, "x /*/***/ x", 'EOF in block comment'); | 43 check(g, a, "x /*/***/ x", 'EOF in block comment'); |
44 check(g, a, "x /*/*/x**/**/ x", '[x,x]'); | 44 check(g, a, "x /*/*/x**/**/ x", '[x,x]'); |
45 | 45 |
46 check(g, a, @""" | 46 check(g, a, r""" |
47 /* Comment */ | 47 /* Comment */ |
48 /* Following comment with /* nested comment*/ */ | 48 /* Following comment with /* nested comment*/ */ |
49 x | 49 x |
50 /* x in comment */ | 50 /* x in comment */ |
51 x /* outside comment */ | 51 x /* outside comment */ |
52 """, | 52 """, |
53 '[x,x]'); | 53 '[x,x]'); |
54 } | 54 } |
55 | 55 |
56 testTEXT() { | 56 testTEXT() { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 Symbol mult_e = g['mult_e']; | 119 Symbol mult_e = g['mult_e']; |
120 Symbol add_e = g['add_e']; | 120 Symbol add_e = g['add_e']; |
121 Symbol shift_e = g['shift_e']; | 121 Symbol shift_e = g['shift_e']; |
122 Symbol relational_e = g['relational_e']; | 122 Symbol relational_e = g['relational_e']; |
123 Symbol equality_e = g['equality_e']; | 123 Symbol equality_e = g['equality_e']; |
124 Symbol cond_e = g['cond_e']; | 124 Symbol cond_e = g['cond_e']; |
125 Symbol assignment_e = g['assignment_e']; | 125 Symbol assignment_e = g['assignment_e']; |
126 | 126 |
127 // Lexical elements. | 127 // Lexical elements. |
128 var idStartChar = CHAR( | 128 var idStartChar = CHAR( |
129 @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); | 129 r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); |
130 var idNextChar = CHAR( | 130 var idNextChar = CHAR( |
131 @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$_"); | 131 r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$_"); |
132 | 132 |
133 var id = TEXT(LEX('identifier', [idStartChar, MANY(idNextChar, min: 0)])); | 133 var id = TEXT(LEX('identifier', [idStartChar, MANY(idNextChar, min: 0)])); |
134 | 134 |
135 var lit = TEXT(LEX('literal', MANY(CHAR('0123456789')))); | 135 var lit = TEXT(LEX('literal', MANY(CHAR('0123456789')))); |
136 | 136 |
137 | 137 |
138 var type_name = id; | 138 var type_name = id; |
139 | 139 |
140 | 140 |
141 // Expression grammar. | 141 // Expression grammar. |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 | 339 |
340 main() { | 340 main() { |
341 testCODE(); | 341 testCODE(); |
342 testParens(); | 342 testParens(); |
343 testOR(); | 343 testOR(); |
344 testTEXT(); | 344 testTEXT(); |
345 testBlockComment(); | 345 testBlockComment(); |
346 testC(); | 346 testC(); |
347 } | 347 } |
OLD | NEW |