cast 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +6 -1
- data/Gemfile +8 -1
- data/README.markdown +144 -168
- data/Rakefile +2 -2
- data/cast.gemspec +0 -3
- data/ext/yylex.re +19 -3
- data/lib/cast/c_nodes.rb +1 -0
- data/lib/cast/node_list.rb +9 -9
- data/lib/cast/preprocessor.rb +7 -20
- data/lib/cast/to_s.rb +38 -2
- data/lib/cast/version.rb +1 -1
- data/test/c_nodes_test.rb +2 -2
- data/test/lexer_test.rb +20 -8
- data/test/node_list_test.rb +18 -18
- data/test/node_test.rb +44 -44
- data/test/parse_test.rb +634 -634
- data/test/parser_test.rb +31 -31
- data/test/preprocessor_test.rb +13 -15
- data/test/render_test.rb +34 -4
- data/test/test_helper.rb +8 -5
- metadata +11 -51
data/test/parse_test.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
require 'test_helper'
|
8
8
|
|
9
|
-
class MatchTest < Test
|
9
|
+
class MatchTest < Minitest::Test
|
10
10
|
def setup
|
11
11
|
C.default_parser = C::Parser.new
|
12
12
|
end
|
@@ -76,7 +76,7 @@ class MatchTest < Test::Unit::TestCase
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
class ParseTests < Test
|
79
|
+
class ParseTests < Minitest::Test
|
80
80
|
def check(klass, s)
|
81
81
|
check_ast(s){|inp| klass.parse(inp)}
|
82
82
|
end
|
@@ -105,7 +105,7 @@ TranslationUnit
|
|
105
105
|
type: Void
|
106
106
|
name: "f"
|
107
107
|
EOS
|
108
|
-
|
108
|
+
assert_raises(C::ParseError){C::TranslationUnit.parse('')}
|
109
109
|
end
|
110
110
|
|
111
111
|
def test_declaration
|
@@ -129,9 +129,9 @@ Declaration
|
|
129
129
|
- Declarator
|
130
130
|
name: "j"
|
131
131
|
EOS
|
132
|
-
|
133
|
-
|
134
|
-
|
132
|
+
assert_raises(C::ParseError){C::Declaration.parse('int i; int j;')}
|
133
|
+
assert_raises(C::ParseError){C::Declaration.parse('int f() {}')}
|
134
|
+
assert_raises(C::ParseError){C::Declaration.parse('')}
|
135
135
|
end
|
136
136
|
|
137
137
|
def test_parameter
|
@@ -160,12 +160,12 @@ void
|
|
160
160
|
Parameter
|
161
161
|
type: Void
|
162
162
|
EOS
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
163
|
+
assert_raises(C::ParseError){C::Parameter.parse('...')}
|
164
|
+
assert_raises(C::ParseError){C::Parameter.parse(') {} void (')}
|
165
|
+
assert_raises(C::ParseError){C::Parameter.parse('); void(')}
|
166
|
+
assert_raises(C::ParseError){C::Parameter.parse('i,j')}
|
167
|
+
assert_raises(C::ParseError){C::Parameter.parse('int,float')}
|
168
|
+
assert_raises(C::ParseError){C::Parameter.parse('')}
|
169
169
|
end
|
170
170
|
|
171
171
|
def test_declarator
|
@@ -224,13 +224,13 @@ Declarator
|
|
224
224
|
name: "argv"
|
225
225
|
name: "x"
|
226
226
|
EOS
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
227
|
+
assert_raises(C::ParseError){C::Declarator.parse('i:1;}; struct {int i')}
|
228
|
+
assert_raises(C::ParseError){C::Declarator.parse('i:1; int j')}
|
229
|
+
assert_raises(C::ParseError){C::Declarator.parse('i:1,j')}
|
230
|
+
assert_raises(C::ParseError){C::Declarator.parse('f; int f;')}
|
231
|
+
assert_raises(C::ParseError){C::Declarator.parse('i,j')}
|
232
|
+
assert_raises(C::ParseError){C::Declarator.parse(';')}
|
233
|
+
assert_raises(C::ParseError){C::Declarator.parse('')}
|
234
234
|
end
|
235
235
|
|
236
236
|
def test_function_def
|
@@ -255,11 +255,11 @@ FunctionDef
|
|
255
255
|
type: Void
|
256
256
|
name: "f"
|
257
257
|
EOS
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
258
|
+
assert_raises(C::ParseError){C::FunctionDef.parse('void f(); void g();')}
|
259
|
+
assert_raises(C::ParseError){C::FunctionDef.parse('int i;')}
|
260
|
+
assert_raises(C::ParseError){C::FunctionDef.parse('void f();')}
|
261
|
+
assert_raises(C::ParseError){C::FunctionDef.parse(';')}
|
262
|
+
assert_raises(C::ParseError){C::FunctionDef.parse('')}
|
263
263
|
end
|
264
264
|
|
265
265
|
def test_enumerator
|
@@ -277,10 +277,10 @@ Enumerator
|
|
277
277
|
val: IntLiteral
|
278
278
|
val: 10
|
279
279
|
EOS
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
280
|
+
assert_raises(C::ParseError){C::Enumerator.parse('} enum {')}
|
281
|
+
assert_raises(C::ParseError){C::Enumerator.parse('} f() {')}
|
282
|
+
assert_raises(C::ParseError){C::Enumerator.parse('X, Y')}
|
283
|
+
assert_raises(C::ParseError){C::Enumerator.parse('')}
|
284
284
|
end
|
285
285
|
|
286
286
|
def test_member_initializer
|
@@ -327,12 +327,12 @@ MemberInit
|
|
327
327
|
init: FloatLiteral
|
328
328
|
val: 10.0
|
329
329
|
EOS
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
330
|
+
assert_raises(C::ParseError){C::MemberInit.parse('} int f() {')}
|
331
|
+
assert_raises(C::ParseError){C::MemberInit.parse('}} f() {{')}
|
332
|
+
assert_raises(C::ParseError){C::MemberInit.parse('1}; x = {1')}
|
333
|
+
assert_raises(C::ParseError){C::MemberInit.parse('1}, y')}
|
334
|
+
assert_raises(C::ParseError){C::MemberInit.parse('1, 2')}
|
335
|
+
assert_raises(C::ParseError){C::MemberInit.parse('')}
|
336
336
|
end
|
337
337
|
|
338
338
|
def test_member
|
@@ -342,12 +342,12 @@ x
|
|
342
342
|
Member
|
343
343
|
name: "x"
|
344
344
|
EOS
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
345
|
+
assert_raises(C::ParseError){C::Member.parse('a = 1};} int f() {struct s x = {a')}
|
346
|
+
assert_raises(C::ParseError){C::Member.parse('a = 1}; struct s y = {.a')}
|
347
|
+
assert_raises(C::ParseError){C::Member.parse('a = 1}, x = {.a')}
|
348
|
+
assert_raises(C::ParseError){C::Member.parse('x = 1, y')}
|
349
|
+
assert_raises(C::ParseError){C::Member.parse('1')}
|
350
|
+
assert_raises(C::ParseError){C::Member.parse('a .b')}
|
351
351
|
end
|
352
352
|
|
353
353
|
def test_block
|
@@ -363,11 +363,11 @@ Block
|
|
363
363
|
stmts:
|
364
364
|
- Block
|
365
365
|
EOS
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
366
|
+
assert_raises(C::ParseError){C::Block.parse('} void f() {')}
|
367
|
+
assert_raises(C::ParseError){C::Block.parse(';;')}
|
368
|
+
assert_raises(C::ParseError){C::Block.parse('int i;')}
|
369
|
+
assert_raises(C::ParseError){C::Block.parse(';')}
|
370
|
+
assert_raises(C::ParseError){C::Block.parse('')}
|
371
371
|
end
|
372
372
|
|
373
373
|
def test_if
|
@@ -394,11 +394,11 @@ If
|
|
394
394
|
expr: IntLiteral
|
395
395
|
val: 20
|
396
396
|
EOS
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
397
|
+
assert_raises(C::ParseError){C::If.parse('} void f() {')}
|
398
|
+
assert_raises(C::ParseError){C::If.parse(';;')}
|
399
|
+
assert_raises(C::ParseError){C::If.parse('int i;')}
|
400
|
+
assert_raises(C::ParseError){C::If.parse(';')}
|
401
|
+
assert_raises(C::ParseError){C::If.parse('')}
|
402
402
|
end
|
403
403
|
|
404
404
|
def test_switch
|
@@ -410,11 +410,11 @@ Switch
|
|
410
410
|
name: "x"
|
411
411
|
stmt: ExpressionStatement
|
412
412
|
EOS
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
413
|
+
assert_raises(C::ParseError){C::Switch.parse('} void f() {')}
|
414
|
+
assert_raises(C::ParseError){C::Switch.parse(';;')}
|
415
|
+
assert_raises(C::ParseError){C::Switch.parse('int i;')}
|
416
|
+
assert_raises(C::ParseError){C::Switch.parse(';')}
|
417
|
+
assert_raises(C::ParseError){C::Switch.parse('')}
|
418
418
|
end
|
419
419
|
|
420
420
|
def test_while
|
@@ -434,11 +434,11 @@ While (do)
|
|
434
434
|
val: 1
|
435
435
|
stmt: ExpressionStatement
|
436
436
|
EOS
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
437
|
+
assert_raises(C::ParseError){C::While.parse('} void f() {')}
|
438
|
+
assert_raises(C::ParseError){C::While.parse(';;')}
|
439
|
+
assert_raises(C::ParseError){C::While.parse('int i;')}
|
440
|
+
assert_raises(C::ParseError){C::While.parse(';')}
|
441
|
+
assert_raises(C::ParseError){C::While.parse('')}
|
442
442
|
end
|
443
443
|
|
444
444
|
def test_for
|
@@ -459,11 +459,11 @@ For
|
|
459
459
|
name: "i"
|
460
460
|
stmt: ExpressionStatement
|
461
461
|
EOS
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
462
|
+
assert_raises(C::ParseError){C::For.parse('} void f() {')}
|
463
|
+
assert_raises(C::ParseError){C::For.parse(';;')}
|
464
|
+
assert_raises(C::ParseError){C::For.parse('int i;')}
|
465
|
+
assert_raises(C::ParseError){C::For.parse(';')}
|
466
|
+
assert_raises(C::ParseError){C::For.parse('')}
|
467
467
|
end
|
468
468
|
|
469
469
|
def test_goto
|
@@ -473,11 +473,11 @@ goto x;
|
|
473
473
|
Goto
|
474
474
|
target: "x"
|
475
475
|
EOS
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
476
|
+
assert_raises(C::ParseError){C::Goto.parse('} void f() {')}
|
477
|
+
assert_raises(C::ParseError){C::Goto.parse(';;')}
|
478
|
+
assert_raises(C::ParseError){C::Goto.parse('int i;')}
|
479
|
+
assert_raises(C::ParseError){C::Goto.parse(';')}
|
480
|
+
assert_raises(C::ParseError){C::Goto.parse('')}
|
481
481
|
end
|
482
482
|
|
483
483
|
def test_continue
|
@@ -486,11 +486,11 @@ continue;
|
|
486
486
|
----
|
487
487
|
Continue
|
488
488
|
EOS
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
489
|
+
assert_raises(C::ParseError){C::Continue.parse('} void f() {')}
|
490
|
+
assert_raises(C::ParseError){C::Continue.parse(';;')}
|
491
|
+
assert_raises(C::ParseError){C::Continue.parse('int i;')}
|
492
|
+
assert_raises(C::ParseError){C::Continue.parse(';')}
|
493
|
+
assert_raises(C::ParseError){C::Continue.parse('')}
|
494
494
|
end
|
495
495
|
|
496
496
|
def test_break
|
@@ -499,11 +499,11 @@ break;
|
|
499
499
|
----
|
500
500
|
Break
|
501
501
|
EOS
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
502
|
+
assert_raises(C::ParseError){C::Break.parse('} void f() {')}
|
503
|
+
assert_raises(C::ParseError){C::Break.parse(';;')}
|
504
|
+
assert_raises(C::ParseError){C::Break.parse('int i;')}
|
505
|
+
assert_raises(C::ParseError){C::Break.parse(';')}
|
506
|
+
assert_raises(C::ParseError){C::Break.parse('')}
|
507
507
|
end
|
508
508
|
|
509
509
|
def test_return
|
@@ -519,11 +519,11 @@ Return
|
|
519
519
|
expr: IntLiteral
|
520
520
|
val: 10
|
521
521
|
EOS
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
522
|
+
assert_raises(C::ParseError){C::Return.parse('} void f() {')}
|
523
|
+
assert_raises(C::ParseError){C::Return.parse(';;')}
|
524
|
+
assert_raises(C::ParseError){C::Return.parse('int i;')}
|
525
|
+
assert_raises(C::ParseError){C::Return.parse(';')}
|
526
|
+
assert_raises(C::ParseError){C::Return.parse('')}
|
527
527
|
end
|
528
528
|
|
529
529
|
def test_expression_statement
|
@@ -539,11 +539,11 @@ ExpressionStatement
|
|
539
539
|
expr: IntLiteral
|
540
540
|
val: 10
|
541
541
|
EOS
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
542
|
+
assert_raises(C::ParseError){C::ExpressionStatement.parse('} void f() {')}
|
543
|
+
assert_raises(C::ParseError){C::ExpressionStatement.parse(';;')}
|
544
|
+
assert_raises(C::ParseError){C::ExpressionStatement.parse('int i;')}
|
545
|
+
assert_raises(C::ParseError){C::ExpressionStatement.parse('return;')}
|
546
|
+
assert_raises(C::ParseError){C::ExpressionStatement.parse('')}
|
547
547
|
end
|
548
548
|
|
549
549
|
def test_statement
|
@@ -621,10 +621,10 @@ EOS
|
|
621
621
|
----
|
622
622
|
ExpressionStatement
|
623
623
|
EOS
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
624
|
+
assert_raises(C::ParseError){C::Statement.parse('} void f() {')}
|
625
|
+
assert_raises(C::ParseError){C::Statement.parse(';;')}
|
626
|
+
assert_raises(C::ParseError){C::Statement.parse('int i;')}
|
627
|
+
assert_raises(C::ParseError){C::Statement.parse('')}
|
628
628
|
end
|
629
629
|
|
630
630
|
def test_plain_label
|
@@ -634,12 +634,12 @@ x:
|
|
634
634
|
PlainLabel
|
635
635
|
name: "x"
|
636
636
|
EOS
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
637
|
+
assert_raises(C::ParseError){C::PlainLabel.parse('} void f() {')}
|
638
|
+
assert_raises(C::ParseError){C::PlainLabel.parse(';')}
|
639
|
+
assert_raises(C::ParseError){C::PlainLabel.parse('')}
|
640
|
+
assert_raises(C::ParseError){C::PlainLabel.parse('x')}
|
641
|
+
assert_raises(C::ParseError){C::PlainLabel.parse('case 1:')}
|
642
|
+
assert_raises(C::ParseError){C::PlainLabel.parse('default:')}
|
643
643
|
end
|
644
644
|
|
645
645
|
def test_default
|
@@ -648,12 +648,12 @@ default:
|
|
648
648
|
----
|
649
649
|
Default
|
650
650
|
EOS
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
651
|
+
assert_raises(C::ParseError){C::Default.parse('} void f() {')}
|
652
|
+
assert_raises(C::ParseError){C::Default.parse(';')}
|
653
|
+
assert_raises(C::ParseError){C::Default.parse('')}
|
654
|
+
assert_raises(C::ParseError){C::Default.parse('x')}
|
655
|
+
assert_raises(C::ParseError){C::Default.parse('x:')}
|
656
|
+
assert_raises(C::ParseError){C::Default.parse('case 1:')}
|
657
657
|
end
|
658
658
|
|
659
659
|
def test_case
|
@@ -664,11 +664,11 @@ Case
|
|
664
664
|
expr: IntLiteral
|
665
665
|
val: 1
|
666
666
|
EOS
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
667
|
+
assert_raises(C::ParseError){C::Case.parse('} void f() {')}
|
668
|
+
assert_raises(C::ParseError){C::Case.parse(';')}
|
669
|
+
assert_raises(C::ParseError){C::Case.parse('')}
|
670
|
+
assert_raises(C::ParseError){C::Case.parse('x:')}
|
671
|
+
assert_raises(C::ParseError){C::Case.parse('default:')}
|
672
672
|
end
|
673
673
|
|
674
674
|
def test_label
|
@@ -690,10 +690,10 @@ Case
|
|
690
690
|
expr: IntLiteral
|
691
691
|
val: 1
|
692
692
|
EOS
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
693
|
+
assert_raises(C::ParseError){C::Label.parse('} void f() {')}
|
694
|
+
assert_raises(C::ParseError){C::Label.parse(';')}
|
695
|
+
assert_raises(C::ParseError){C::Label.parse('')}
|
696
|
+
assert_raises(C::ParseError){C::Label.parse('x')}
|
697
697
|
end
|
698
698
|
|
699
699
|
def test_comma
|
@@ -721,15 +721,15 @@ Comma
|
|
721
721
|
expr: Variable
|
722
722
|
name: "j"
|
723
723
|
EOS
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
724
|
+
assert_raises(C::ParseError){C::Comma.parse('} void f() {')}
|
725
|
+
assert_raises(C::ParseError){C::Comma.parse(';')}
|
726
|
+
assert_raises(C::ParseError){C::Comma.parse('int i')}
|
727
|
+
assert_raises(C::ParseError){C::Comma.parse('int')}
|
728
|
+
assert_raises(C::ParseError){C::Comma.parse('if (0)')}
|
729
|
+
assert_raises(C::ParseError){C::Comma.parse('switch (0)')}
|
730
|
+
assert_raises(C::ParseError){C::Comma.parse('for (;;)')}
|
731
|
+
assert_raises(C::ParseError){C::Comma.parse('goto')}
|
732
|
+
assert_raises(C::ParseError){C::Comma.parse('return')}
|
733
733
|
end
|
734
734
|
|
735
735
|
def test_conditional
|
@@ -744,15 +744,15 @@ Conditional
|
|
744
744
|
else: IntLiteral
|
745
745
|
val: 20
|
746
746
|
EOS
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
747
|
+
assert_raises(C::ParseError){C::Conditional.parse('} void f() {')}
|
748
|
+
assert_raises(C::ParseError){C::Conditional.parse(';')}
|
749
|
+
assert_raises(C::ParseError){C::Conditional.parse('int i')}
|
750
|
+
assert_raises(C::ParseError){C::Conditional.parse('int')}
|
751
|
+
assert_raises(C::ParseError){C::Conditional.parse('if (0)')}
|
752
|
+
assert_raises(C::ParseError){C::Conditional.parse('switch (0)')}
|
753
|
+
assert_raises(C::ParseError){C::Conditional.parse('for (;;)')}
|
754
|
+
assert_raises(C::ParseError){C::Conditional.parse('goto')}
|
755
|
+
assert_raises(C::ParseError){C::Conditional.parse('return')}
|
756
756
|
end
|
757
757
|
|
758
758
|
def test_cast
|
@@ -764,15 +764,15 @@ Cast
|
|
764
764
|
expr: FloatLiteral
|
765
765
|
val: 10.0
|
766
766
|
EOS
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
767
|
+
assert_raises(C::ParseError){C::Cast.parse('} void f() {')}
|
768
|
+
assert_raises(C::ParseError){C::Cast.parse(';')}
|
769
|
+
assert_raises(C::ParseError){C::Cast.parse('int i')}
|
770
|
+
assert_raises(C::ParseError){C::Cast.parse('int')}
|
771
|
+
assert_raises(C::ParseError){C::Cast.parse('if (0)')}
|
772
|
+
assert_raises(C::ParseError){C::Cast.parse('switch (0)')}
|
773
|
+
assert_raises(C::ParseError){C::Cast.parse('for (;;)')}
|
774
|
+
assert_raises(C::ParseError){C::Cast.parse('goto')}
|
775
|
+
assert_raises(C::ParseError){C::Cast.parse('return')}
|
776
776
|
end
|
777
777
|
|
778
778
|
def test_address
|
@@ -783,15 +783,15 @@ Address
|
|
783
783
|
expr: Variable
|
784
784
|
name: "x"
|
785
785
|
EOS
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
786
|
+
assert_raises(C::ParseError){C::Address.parse('} void f() {')}
|
787
|
+
assert_raises(C::ParseError){C::Address.parse(';')}
|
788
|
+
assert_raises(C::ParseError){C::Address.parse('int i')}
|
789
|
+
assert_raises(C::ParseError){C::Address.parse('int')}
|
790
|
+
assert_raises(C::ParseError){C::Address.parse('if (0)')}
|
791
|
+
assert_raises(C::ParseError){C::Address.parse('switch (0)')}
|
792
|
+
assert_raises(C::ParseError){C::Address.parse('for (;;)')}
|
793
|
+
assert_raises(C::ParseError){C::Address.parse('goto')}
|
794
|
+
assert_raises(C::ParseError){C::Address.parse('return')}
|
795
795
|
end
|
796
796
|
|
797
797
|
def test_dereference
|
@@ -802,15 +802,15 @@ Dereference
|
|
802
802
|
expr: Variable
|
803
803
|
name: "x"
|
804
804
|
EOS
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
805
|
+
assert_raises(C::ParseError){C::Dereference.parse('} void f() {')}
|
806
|
+
assert_raises(C::ParseError){C::Dereference.parse(';')}
|
807
|
+
assert_raises(C::ParseError){C::Dereference.parse('int i')}
|
808
|
+
assert_raises(C::ParseError){C::Dereference.parse('int')}
|
809
|
+
assert_raises(C::ParseError){C::Dereference.parse('if (0)')}
|
810
|
+
assert_raises(C::ParseError){C::Dereference.parse('switch (0)')}
|
811
|
+
assert_raises(C::ParseError){C::Dereference.parse('for (;;)')}
|
812
|
+
assert_raises(C::ParseError){C::Dereference.parse('goto')}
|
813
|
+
assert_raises(C::ParseError){C::Dereference.parse('return')}
|
814
814
|
end
|
815
815
|
|
816
816
|
def test_sizeof
|
@@ -827,15 +827,15 @@ sizeof(int)
|
|
827
827
|
Sizeof
|
828
828
|
expr: Int
|
829
829
|
EOS
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
830
|
+
assert_raises(C::ParseError){C::Sizeof.parse('} void f() {')}
|
831
|
+
assert_raises(C::ParseError){C::Sizeof.parse(';')}
|
832
|
+
assert_raises(C::ParseError){C::Sizeof.parse('int i')}
|
833
|
+
assert_raises(C::ParseError){C::Sizeof.parse('int')}
|
834
|
+
assert_raises(C::ParseError){C::Sizeof.parse('if (0)')}
|
835
|
+
assert_raises(C::ParseError){C::Sizeof.parse('switch (0)')}
|
836
|
+
assert_raises(C::ParseError){C::Sizeof.parse('for (;;)')}
|
837
|
+
assert_raises(C::ParseError){C::Sizeof.parse('goto')}
|
838
|
+
assert_raises(C::ParseError){C::Sizeof.parse('return')}
|
839
839
|
end
|
840
840
|
|
841
841
|
def test_index
|
@@ -851,15 +851,15 @@ Index
|
|
851
851
|
index: IntLiteral
|
852
852
|
val: 20
|
853
853
|
EOS
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
854
|
+
assert_raises(C::ParseError){C::Index.parse('} void f() {')}
|
855
|
+
assert_raises(C::ParseError){C::Index.parse(';')}
|
856
|
+
assert_raises(C::ParseError){C::Index.parse('int i')}
|
857
|
+
assert_raises(C::ParseError){C::Index.parse('int')}
|
858
|
+
assert_raises(C::ParseError){C::Index.parse('if (0)')}
|
859
|
+
assert_raises(C::ParseError){C::Index.parse('switch (0)')}
|
860
|
+
assert_raises(C::ParseError){C::Index.parse('for (;;)')}
|
861
|
+
assert_raises(C::ParseError){C::Index.parse('goto')}
|
862
|
+
assert_raises(C::ParseError){C::Index.parse('return')}
|
863
863
|
end
|
864
864
|
|
865
865
|
def test_call
|
@@ -876,15 +876,15 @@ Call
|
|
876
876
|
- IntLiteral
|
877
877
|
val: 20
|
878
878
|
EOS
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
879
|
+
assert_raises(C::ParseError){C::Call.parse('} void f() {')}
|
880
|
+
assert_raises(C::ParseError){C::Call.parse(';')}
|
881
|
+
assert_raises(C::ParseError){C::Call.parse('int i')}
|
882
|
+
assert_raises(C::ParseError){C::Call.parse('int')}
|
883
|
+
assert_raises(C::ParseError){C::Call.parse('if (0)')}
|
884
|
+
assert_raises(C::ParseError){C::Call.parse('switch (0)')}
|
885
|
+
assert_raises(C::ParseError){C::Call.parse('for (;;)')}
|
886
|
+
assert_raises(C::ParseError){C::Call.parse('goto')}
|
887
|
+
assert_raises(C::ParseError){C::Call.parse('return')}
|
888
888
|
end
|
889
889
|
|
890
890
|
def test_arrow
|
@@ -897,15 +897,15 @@ Arrow
|
|
897
897
|
member: Member
|
898
898
|
name: "y"
|
899
899
|
EOS
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
900
|
+
assert_raises(C::ParseError){C::Arrow.parse('} void f() {')}
|
901
|
+
assert_raises(C::ParseError){C::Arrow.parse(';')}
|
902
|
+
assert_raises(C::ParseError){C::Arrow.parse('int i')}
|
903
|
+
assert_raises(C::ParseError){C::Arrow.parse('int')}
|
904
|
+
assert_raises(C::ParseError){C::Arrow.parse('if (0)')}
|
905
|
+
assert_raises(C::ParseError){C::Arrow.parse('switch (0)')}
|
906
|
+
assert_raises(C::ParseError){C::Arrow.parse('for (;;)')}
|
907
|
+
assert_raises(C::ParseError){C::Arrow.parse('goto')}
|
908
|
+
assert_raises(C::ParseError){C::Arrow.parse('return')}
|
909
909
|
end
|
910
910
|
|
911
911
|
def test_dot
|
@@ -918,15 +918,15 @@ Dot
|
|
918
918
|
member: Member
|
919
919
|
name: "y"
|
920
920
|
EOS
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
921
|
+
assert_raises(C::ParseError){C::Dot.parse('} void f() {')}
|
922
|
+
assert_raises(C::ParseError){C::Dot.parse(';')}
|
923
|
+
assert_raises(C::ParseError){C::Dot.parse('int i')}
|
924
|
+
assert_raises(C::ParseError){C::Dot.parse('int')}
|
925
|
+
assert_raises(C::ParseError){C::Dot.parse('if (0)')}
|
926
|
+
assert_raises(C::ParseError){C::Dot.parse('switch (0)')}
|
927
|
+
assert_raises(C::ParseError){C::Dot.parse('for (;;)')}
|
928
|
+
assert_raises(C::ParseError){C::Dot.parse('goto')}
|
929
|
+
assert_raises(C::ParseError){C::Dot.parse('return')}
|
930
930
|
end
|
931
931
|
|
932
932
|
def test_positive
|
@@ -937,15 +937,15 @@ Positive
|
|
937
937
|
expr: IntLiteral
|
938
938
|
val: 1
|
939
939
|
EOS
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
940
|
+
assert_raises(C::ParseError){C::Positive.parse('} void f() {')}
|
941
|
+
assert_raises(C::ParseError){C::Positive.parse(';')}
|
942
|
+
assert_raises(C::ParseError){C::Positive.parse('int i')}
|
943
|
+
assert_raises(C::ParseError){C::Positive.parse('int')}
|
944
|
+
assert_raises(C::ParseError){C::Positive.parse('if (0)')}
|
945
|
+
assert_raises(C::ParseError){C::Positive.parse('switch (0)')}
|
946
|
+
assert_raises(C::ParseError){C::Positive.parse('for (;;)')}
|
947
|
+
assert_raises(C::ParseError){C::Positive.parse('goto')}
|
948
|
+
assert_raises(C::ParseError){C::Positive.parse('return')}
|
949
949
|
end
|
950
950
|
|
951
951
|
def test_negative
|
@@ -956,15 +956,15 @@ Negative
|
|
956
956
|
expr: IntLiteral
|
957
957
|
val: 1
|
958
958
|
EOS
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
959
|
+
assert_raises(C::ParseError){C::Negative.parse('} void f() {')}
|
960
|
+
assert_raises(C::ParseError){C::Negative.parse(';')}
|
961
|
+
assert_raises(C::ParseError){C::Negative.parse('int i')}
|
962
|
+
assert_raises(C::ParseError){C::Negative.parse('int')}
|
963
|
+
assert_raises(C::ParseError){C::Negative.parse('if (0)')}
|
964
|
+
assert_raises(C::ParseError){C::Negative.parse('switch (0)')}
|
965
|
+
assert_raises(C::ParseError){C::Negative.parse('for (;;)')}
|
966
|
+
assert_raises(C::ParseError){C::Negative.parse('goto')}
|
967
|
+
assert_raises(C::ParseError){C::Negative.parse('return')}
|
968
968
|
end
|
969
969
|
|
970
970
|
def test_add
|
@@ -977,15 +977,15 @@ Add
|
|
977
977
|
expr2: IntLiteral
|
978
978
|
val: 10
|
979
979
|
EOS
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
980
|
+
assert_raises(C::ParseError){C::Add.parse('} void f() {')}
|
981
|
+
assert_raises(C::ParseError){C::Add.parse(';')}
|
982
|
+
assert_raises(C::ParseError){C::Add.parse('int i')}
|
983
|
+
assert_raises(C::ParseError){C::Add.parse('int')}
|
984
|
+
assert_raises(C::ParseError){C::Add.parse('if (0)')}
|
985
|
+
assert_raises(C::ParseError){C::Add.parse('switch (0)')}
|
986
|
+
assert_raises(C::ParseError){C::Add.parse('for (;;)')}
|
987
|
+
assert_raises(C::ParseError){C::Add.parse('goto')}
|
988
|
+
assert_raises(C::ParseError){C::Add.parse('return')}
|
989
989
|
end
|
990
990
|
|
991
991
|
def test_subtract
|
@@ -998,15 +998,15 @@ Subtract
|
|
998
998
|
expr2: IntLiteral
|
999
999
|
val: 10
|
1000
1000
|
EOS
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1001
|
+
assert_raises(C::ParseError){C::Subtract.parse('} void f() {')}
|
1002
|
+
assert_raises(C::ParseError){C::Subtract.parse(';')}
|
1003
|
+
assert_raises(C::ParseError){C::Subtract.parse('int i')}
|
1004
|
+
assert_raises(C::ParseError){C::Subtract.parse('int')}
|
1005
|
+
assert_raises(C::ParseError){C::Subtract.parse('if (0)')}
|
1006
|
+
assert_raises(C::ParseError){C::Subtract.parse('switch (0)')}
|
1007
|
+
assert_raises(C::ParseError){C::Subtract.parse('for (;;)')}
|
1008
|
+
assert_raises(C::ParseError){C::Subtract.parse('goto')}
|
1009
|
+
assert_raises(C::ParseError){C::Subtract.parse('return')}
|
1010
1010
|
end
|
1011
1011
|
|
1012
1012
|
def test_multiply
|
@@ -1019,15 +1019,15 @@ Multiply
|
|
1019
1019
|
expr2: IntLiteral
|
1020
1020
|
val: 10
|
1021
1021
|
EOS
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1022
|
+
assert_raises(C::ParseError){C::Multiply.parse('} void f() {')}
|
1023
|
+
assert_raises(C::ParseError){C::Multiply.parse(';')}
|
1024
|
+
assert_raises(C::ParseError){C::Multiply.parse('int i')}
|
1025
|
+
assert_raises(C::ParseError){C::Multiply.parse('int')}
|
1026
|
+
assert_raises(C::ParseError){C::Multiply.parse('if (0)')}
|
1027
|
+
assert_raises(C::ParseError){C::Multiply.parse('switch (0)')}
|
1028
|
+
assert_raises(C::ParseError){C::Multiply.parse('for (;;)')}
|
1029
|
+
assert_raises(C::ParseError){C::Multiply.parse('goto')}
|
1030
|
+
assert_raises(C::ParseError){C::Multiply.parse('return')}
|
1031
1031
|
end
|
1032
1032
|
|
1033
1033
|
def test_divide
|
@@ -1040,15 +1040,15 @@ Divide
|
|
1040
1040
|
expr2: IntLiteral
|
1041
1041
|
val: 10
|
1042
1042
|
EOS
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1043
|
+
assert_raises(C::ParseError){C::Divide.parse('} void f() {')}
|
1044
|
+
assert_raises(C::ParseError){C::Divide.parse(';')}
|
1045
|
+
assert_raises(C::ParseError){C::Divide.parse('int i')}
|
1046
|
+
assert_raises(C::ParseError){C::Divide.parse('int')}
|
1047
|
+
assert_raises(C::ParseError){C::Divide.parse('if (0)')}
|
1048
|
+
assert_raises(C::ParseError){C::Divide.parse('switch (0)')}
|
1049
|
+
assert_raises(C::ParseError){C::Divide.parse('for (;;)')}
|
1050
|
+
assert_raises(C::ParseError){C::Divide.parse('goto')}
|
1051
|
+
assert_raises(C::ParseError){C::Divide.parse('return')}
|
1052
1052
|
end
|
1053
1053
|
|
1054
1054
|
def test_mod
|
@@ -1061,15 +1061,15 @@ Mod
|
|
1061
1061
|
expr2: IntLiteral
|
1062
1062
|
val: 10
|
1063
1063
|
EOS
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1064
|
+
assert_raises(C::ParseError){C::Mod.parse('} void f() {')}
|
1065
|
+
assert_raises(C::ParseError){C::Mod.parse(';')}
|
1066
|
+
assert_raises(C::ParseError){C::Mod.parse('int i')}
|
1067
|
+
assert_raises(C::ParseError){C::Mod.parse('int')}
|
1068
|
+
assert_raises(C::ParseError){C::Mod.parse('if (0)')}
|
1069
|
+
assert_raises(C::ParseError){C::Mod.parse('switch (0)')}
|
1070
|
+
assert_raises(C::ParseError){C::Mod.parse('for (;;)')}
|
1071
|
+
assert_raises(C::ParseError){C::Mod.parse('goto')}
|
1072
|
+
assert_raises(C::ParseError){C::Mod.parse('return')}
|
1073
1073
|
end
|
1074
1074
|
|
1075
1075
|
def test_pre_inc
|
@@ -1080,15 +1080,15 @@ PreInc
|
|
1080
1080
|
expr: Variable
|
1081
1081
|
name: "i"
|
1082
1082
|
EOS
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1083
|
+
assert_raises(C::ParseError){C::PreInc.parse('} void f() {')}
|
1084
|
+
assert_raises(C::ParseError){C::PreInc.parse(';')}
|
1085
|
+
assert_raises(C::ParseError){C::PreInc.parse('int i')}
|
1086
|
+
assert_raises(C::ParseError){C::PreInc.parse('int')}
|
1087
|
+
assert_raises(C::ParseError){C::PreInc.parse('if (0)')}
|
1088
|
+
assert_raises(C::ParseError){C::PreInc.parse('switch (0)')}
|
1089
|
+
assert_raises(C::ParseError){C::PreInc.parse('for (;;)')}
|
1090
|
+
assert_raises(C::ParseError){C::PreInc.parse('goto')}
|
1091
|
+
assert_raises(C::ParseError){C::PreInc.parse('return')}
|
1092
1092
|
end
|
1093
1093
|
|
1094
1094
|
def test_post_inc
|
@@ -1099,15 +1099,15 @@ PostInc
|
|
1099
1099
|
expr: Variable
|
1100
1100
|
name: "i"
|
1101
1101
|
EOS
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1102
|
+
assert_raises(C::ParseError){C::PostInc.parse('} void f() {')}
|
1103
|
+
assert_raises(C::ParseError){C::PostInc.parse(';')}
|
1104
|
+
assert_raises(C::ParseError){C::PostInc.parse('int i')}
|
1105
|
+
assert_raises(C::ParseError){C::PostInc.parse('int')}
|
1106
|
+
assert_raises(C::ParseError){C::PostInc.parse('if (0)')}
|
1107
|
+
assert_raises(C::ParseError){C::PostInc.parse('switch (0)')}
|
1108
|
+
assert_raises(C::ParseError){C::PostInc.parse('for (;;)')}
|
1109
|
+
assert_raises(C::ParseError){C::PostInc.parse('goto')}
|
1110
|
+
assert_raises(C::ParseError){C::PostInc.parse('return')}
|
1111
1111
|
end
|
1112
1112
|
|
1113
1113
|
def test_pre_dec
|
@@ -1118,15 +1118,15 @@ PreDec
|
|
1118
1118
|
expr: Variable
|
1119
1119
|
name: "i"
|
1120
1120
|
EOS
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1121
|
+
assert_raises(C::ParseError){C::PreDec.parse('} void f() {')}
|
1122
|
+
assert_raises(C::ParseError){C::PreDec.parse(';')}
|
1123
|
+
assert_raises(C::ParseError){C::PreDec.parse('int i')}
|
1124
|
+
assert_raises(C::ParseError){C::PreDec.parse('int')}
|
1125
|
+
assert_raises(C::ParseError){C::PreDec.parse('if (0)')}
|
1126
|
+
assert_raises(C::ParseError){C::PreDec.parse('switch (0)')}
|
1127
|
+
assert_raises(C::ParseError){C::PreDec.parse('for (;;)')}
|
1128
|
+
assert_raises(C::ParseError){C::PreDec.parse('goto')}
|
1129
|
+
assert_raises(C::ParseError){C::PreDec.parse('return')}
|
1130
1130
|
end
|
1131
1131
|
|
1132
1132
|
def test_post_dec
|
@@ -1137,15 +1137,15 @@ PostDec
|
|
1137
1137
|
expr: Variable
|
1138
1138
|
name: "i"
|
1139
1139
|
EOS
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1140
|
+
assert_raises(C::ParseError){C::PostDec.parse('} void f() {')}
|
1141
|
+
assert_raises(C::ParseError){C::PostDec.parse(';')}
|
1142
|
+
assert_raises(C::ParseError){C::PostDec.parse('int i')}
|
1143
|
+
assert_raises(C::ParseError){C::PostDec.parse('int')}
|
1144
|
+
assert_raises(C::ParseError){C::PostDec.parse('if (0)')}
|
1145
|
+
assert_raises(C::ParseError){C::PostDec.parse('switch (0)')}
|
1146
|
+
assert_raises(C::ParseError){C::PostDec.parse('for (;;)')}
|
1147
|
+
assert_raises(C::ParseError){C::PostDec.parse('goto')}
|
1148
|
+
assert_raises(C::ParseError){C::PostDec.parse('return')}
|
1149
1149
|
end
|
1150
1150
|
|
1151
1151
|
def test_equal
|
@@ -1158,15 +1158,15 @@ Equal
|
|
1158
1158
|
expr2: IntLiteral
|
1159
1159
|
val: 10
|
1160
1160
|
EOS
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1161
|
+
assert_raises(C::ParseError){C::Equal.parse('} void f() {')}
|
1162
|
+
assert_raises(C::ParseError){C::Equal.parse(';')}
|
1163
|
+
assert_raises(C::ParseError){C::Equal.parse('int i')}
|
1164
|
+
assert_raises(C::ParseError){C::Equal.parse('int')}
|
1165
|
+
assert_raises(C::ParseError){C::Equal.parse('if (0)')}
|
1166
|
+
assert_raises(C::ParseError){C::Equal.parse('switch (0)')}
|
1167
|
+
assert_raises(C::ParseError){C::Equal.parse('for (;;)')}
|
1168
|
+
assert_raises(C::ParseError){C::Equal.parse('goto')}
|
1169
|
+
assert_raises(C::ParseError){C::Equal.parse('return')}
|
1170
1170
|
end
|
1171
1171
|
|
1172
1172
|
def test_not_equal
|
@@ -1179,15 +1179,15 @@ NotEqual
|
|
1179
1179
|
expr2: IntLiteral
|
1180
1180
|
val: 10
|
1181
1181
|
EOS
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1182
|
+
assert_raises(C::ParseError){C::NotEqual.parse('} void f() {')}
|
1183
|
+
assert_raises(C::ParseError){C::NotEqual.parse(';')}
|
1184
|
+
assert_raises(C::ParseError){C::NotEqual.parse('int i')}
|
1185
|
+
assert_raises(C::ParseError){C::NotEqual.parse('int')}
|
1186
|
+
assert_raises(C::ParseError){C::NotEqual.parse('if (0)')}
|
1187
|
+
assert_raises(C::ParseError){C::NotEqual.parse('switch (0)')}
|
1188
|
+
assert_raises(C::ParseError){C::NotEqual.parse('for (;;)')}
|
1189
|
+
assert_raises(C::ParseError){C::NotEqual.parse('goto')}
|
1190
|
+
assert_raises(C::ParseError){C::NotEqual.parse('return')}
|
1191
1191
|
end
|
1192
1192
|
|
1193
1193
|
def test_less
|
@@ -1200,15 +1200,15 @@ Less
|
|
1200
1200
|
expr2: IntLiteral
|
1201
1201
|
val: 10
|
1202
1202
|
EOS
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1203
|
+
assert_raises(C::ParseError){C::Less.parse('} void f() {')}
|
1204
|
+
assert_raises(C::ParseError){C::Less.parse(';')}
|
1205
|
+
assert_raises(C::ParseError){C::Less.parse('int i')}
|
1206
|
+
assert_raises(C::ParseError){C::Less.parse('int')}
|
1207
|
+
assert_raises(C::ParseError){C::Less.parse('if (0)')}
|
1208
|
+
assert_raises(C::ParseError){C::Less.parse('switch (0)')}
|
1209
|
+
assert_raises(C::ParseError){C::Less.parse('for (;;)')}
|
1210
|
+
assert_raises(C::ParseError){C::Less.parse('goto')}
|
1211
|
+
assert_raises(C::ParseError){C::Less.parse('return')}
|
1212
1212
|
end
|
1213
1213
|
|
1214
1214
|
def test_more
|
@@ -1221,15 +1221,15 @@ More
|
|
1221
1221
|
expr2: IntLiteral
|
1222
1222
|
val: 10
|
1223
1223
|
EOS
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1224
|
+
assert_raises(C::ParseError){C::More.parse('} void f() {')}
|
1225
|
+
assert_raises(C::ParseError){C::More.parse(';')}
|
1226
|
+
assert_raises(C::ParseError){C::More.parse('int i')}
|
1227
|
+
assert_raises(C::ParseError){C::More.parse('int')}
|
1228
|
+
assert_raises(C::ParseError){C::More.parse('if (0)')}
|
1229
|
+
assert_raises(C::ParseError){C::More.parse('switch (0)')}
|
1230
|
+
assert_raises(C::ParseError){C::More.parse('for (;;)')}
|
1231
|
+
assert_raises(C::ParseError){C::More.parse('goto')}
|
1232
|
+
assert_raises(C::ParseError){C::More.parse('return')}
|
1233
1233
|
end
|
1234
1234
|
|
1235
1235
|
def test_less_or_equal
|
@@ -1242,15 +1242,15 @@ LessOrEqual
|
|
1242
1242
|
expr2: IntLiteral
|
1243
1243
|
val: 10
|
1244
1244
|
EOS
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1245
|
+
assert_raises(C::ParseError){C::LessOrEqual.parse('} void f() {')}
|
1246
|
+
assert_raises(C::ParseError){C::LessOrEqual.parse(';')}
|
1247
|
+
assert_raises(C::ParseError){C::LessOrEqual.parse('int i')}
|
1248
|
+
assert_raises(C::ParseError){C::LessOrEqual.parse('int')}
|
1249
|
+
assert_raises(C::ParseError){C::LessOrEqual.parse('if (0)')}
|
1250
|
+
assert_raises(C::ParseError){C::LessOrEqual.parse('switch (0)')}
|
1251
|
+
assert_raises(C::ParseError){C::LessOrEqual.parse('for (;;)')}
|
1252
|
+
assert_raises(C::ParseError){C::LessOrEqual.parse('goto')}
|
1253
|
+
assert_raises(C::ParseError){C::LessOrEqual.parse('return')}
|
1254
1254
|
end
|
1255
1255
|
|
1256
1256
|
def test_more_or_equal
|
@@ -1263,15 +1263,15 @@ MoreOrEqual
|
|
1263
1263
|
expr2: IntLiteral
|
1264
1264
|
val: 10
|
1265
1265
|
EOS
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1266
|
+
assert_raises(C::ParseError){C::MoreOrEqual.parse('} void f() {')}
|
1267
|
+
assert_raises(C::ParseError){C::MoreOrEqual.parse(';')}
|
1268
|
+
assert_raises(C::ParseError){C::MoreOrEqual.parse('int i')}
|
1269
|
+
assert_raises(C::ParseError){C::MoreOrEqual.parse('int')}
|
1270
|
+
assert_raises(C::ParseError){C::MoreOrEqual.parse('if (0)')}
|
1271
|
+
assert_raises(C::ParseError){C::MoreOrEqual.parse('switch (0)')}
|
1272
|
+
assert_raises(C::ParseError){C::MoreOrEqual.parse('for (;;)')}
|
1273
|
+
assert_raises(C::ParseError){C::MoreOrEqual.parse('goto')}
|
1274
|
+
assert_raises(C::ParseError){C::MoreOrEqual.parse('return')}
|
1275
1275
|
end
|
1276
1276
|
|
1277
1277
|
def test_bit_and
|
@@ -1284,15 +1284,15 @@ BitAnd
|
|
1284
1284
|
expr2: IntLiteral
|
1285
1285
|
val: 10
|
1286
1286
|
EOS
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1287
|
+
assert_raises(C::ParseError){C::BitAnd.parse('} void f() {')}
|
1288
|
+
assert_raises(C::ParseError){C::BitAnd.parse(';')}
|
1289
|
+
assert_raises(C::ParseError){C::BitAnd.parse('int i')}
|
1290
|
+
assert_raises(C::ParseError){C::BitAnd.parse('int')}
|
1291
|
+
assert_raises(C::ParseError){C::BitAnd.parse('if (0)')}
|
1292
|
+
assert_raises(C::ParseError){C::BitAnd.parse('switch (0)')}
|
1293
|
+
assert_raises(C::ParseError){C::BitAnd.parse('for (;;)')}
|
1294
|
+
assert_raises(C::ParseError){C::BitAnd.parse('goto')}
|
1295
|
+
assert_raises(C::ParseError){C::BitAnd.parse('return')}
|
1296
1296
|
end
|
1297
1297
|
|
1298
1298
|
def test_bit_or
|
@@ -1305,15 +1305,15 @@ BitOr
|
|
1305
1305
|
expr2: IntLiteral
|
1306
1306
|
val: 10
|
1307
1307
|
EOS
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1308
|
+
assert_raises(C::ParseError){C::BitOr.parse('} void f() {')}
|
1309
|
+
assert_raises(C::ParseError){C::BitOr.parse(';')}
|
1310
|
+
assert_raises(C::ParseError){C::BitOr.parse('int i')}
|
1311
|
+
assert_raises(C::ParseError){C::BitOr.parse('int')}
|
1312
|
+
assert_raises(C::ParseError){C::BitOr.parse('if (0)')}
|
1313
|
+
assert_raises(C::ParseError){C::BitOr.parse('switch (0)')}
|
1314
|
+
assert_raises(C::ParseError){C::BitOr.parse('for (;;)')}
|
1315
|
+
assert_raises(C::ParseError){C::BitOr.parse('goto')}
|
1316
|
+
assert_raises(C::ParseError){C::BitOr.parse('return')}
|
1317
1317
|
end
|
1318
1318
|
|
1319
1319
|
def test_bit_xor
|
@@ -1326,15 +1326,15 @@ BitXor
|
|
1326
1326
|
expr2: IntLiteral
|
1327
1327
|
val: 10
|
1328
1328
|
EOS
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1329
|
+
assert_raises(C::ParseError){C::BitXor.parse('} void f() {')}
|
1330
|
+
assert_raises(C::ParseError){C::BitXor.parse(';')}
|
1331
|
+
assert_raises(C::ParseError){C::BitXor.parse('int i')}
|
1332
|
+
assert_raises(C::ParseError){C::BitXor.parse('int')}
|
1333
|
+
assert_raises(C::ParseError){C::BitXor.parse('if (0)')}
|
1334
|
+
assert_raises(C::ParseError){C::BitXor.parse('switch (0)')}
|
1335
|
+
assert_raises(C::ParseError){C::BitXor.parse('for (;;)')}
|
1336
|
+
assert_raises(C::ParseError){C::BitXor.parse('goto')}
|
1337
|
+
assert_raises(C::ParseError){C::BitXor.parse('return')}
|
1338
1338
|
end
|
1339
1339
|
|
1340
1340
|
def test_bit_not
|
@@ -1345,15 +1345,15 @@ BitNot
|
|
1345
1345
|
expr: Variable
|
1346
1346
|
name: "i"
|
1347
1347
|
EOS
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1348
|
+
assert_raises(C::ParseError){C::BitNot.parse('} void f() {')}
|
1349
|
+
assert_raises(C::ParseError){C::BitNot.parse(';')}
|
1350
|
+
assert_raises(C::ParseError){C::BitNot.parse('int i')}
|
1351
|
+
assert_raises(C::ParseError){C::BitNot.parse('int')}
|
1352
|
+
assert_raises(C::ParseError){C::BitNot.parse('if (0)')}
|
1353
|
+
assert_raises(C::ParseError){C::BitNot.parse('switch (0)')}
|
1354
|
+
assert_raises(C::ParseError){C::BitNot.parse('for (;;)')}
|
1355
|
+
assert_raises(C::ParseError){C::BitNot.parse('goto')}
|
1356
|
+
assert_raises(C::ParseError){C::BitNot.parse('return')}
|
1357
1357
|
end
|
1358
1358
|
|
1359
1359
|
def test_shift_left
|
@@ -1366,15 +1366,15 @@ ShiftLeft
|
|
1366
1366
|
expr2: IntLiteral
|
1367
1367
|
val: 10
|
1368
1368
|
EOS
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1369
|
+
assert_raises(C::ParseError){C::ShiftLeft.parse('} void f() {')}
|
1370
|
+
assert_raises(C::ParseError){C::ShiftLeft.parse(';')}
|
1371
|
+
assert_raises(C::ParseError){C::ShiftLeft.parse('int i')}
|
1372
|
+
assert_raises(C::ParseError){C::ShiftLeft.parse('int')}
|
1373
|
+
assert_raises(C::ParseError){C::ShiftLeft.parse('if (0)')}
|
1374
|
+
assert_raises(C::ParseError){C::ShiftLeft.parse('switch (0)')}
|
1375
|
+
assert_raises(C::ParseError){C::ShiftLeft.parse('for (;;)')}
|
1376
|
+
assert_raises(C::ParseError){C::ShiftLeft.parse('goto')}
|
1377
|
+
assert_raises(C::ParseError){C::ShiftLeft.parse('return')}
|
1378
1378
|
end
|
1379
1379
|
|
1380
1380
|
def test_shift_right
|
@@ -1387,15 +1387,15 @@ ShiftRight
|
|
1387
1387
|
expr2: IntLiteral
|
1388
1388
|
val: 10
|
1389
1389
|
EOS
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1390
|
+
assert_raises(C::ParseError){C::ShiftRight.parse('} void f() {')}
|
1391
|
+
assert_raises(C::ParseError){C::ShiftRight.parse(';')}
|
1392
|
+
assert_raises(C::ParseError){C::ShiftRight.parse('int i')}
|
1393
|
+
assert_raises(C::ParseError){C::ShiftRight.parse('int')}
|
1394
|
+
assert_raises(C::ParseError){C::ShiftRight.parse('if (0)')}
|
1395
|
+
assert_raises(C::ParseError){C::ShiftRight.parse('switch (0)')}
|
1396
|
+
assert_raises(C::ParseError){C::ShiftRight.parse('for (;;)')}
|
1397
|
+
assert_raises(C::ParseError){C::ShiftRight.parse('goto')}
|
1398
|
+
assert_raises(C::ParseError){C::ShiftRight.parse('return')}
|
1399
1399
|
end
|
1400
1400
|
|
1401
1401
|
def test_and
|
@@ -1408,15 +1408,15 @@ And
|
|
1408
1408
|
expr2: IntLiteral
|
1409
1409
|
val: 10
|
1410
1410
|
EOS
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1411
|
+
assert_raises(C::ParseError){C::And.parse('} void f() {')}
|
1412
|
+
assert_raises(C::ParseError){C::And.parse(';')}
|
1413
|
+
assert_raises(C::ParseError){C::And.parse('int i')}
|
1414
|
+
assert_raises(C::ParseError){C::And.parse('int')}
|
1415
|
+
assert_raises(C::ParseError){C::And.parse('if (0)')}
|
1416
|
+
assert_raises(C::ParseError){C::And.parse('switch (0)')}
|
1417
|
+
assert_raises(C::ParseError){C::And.parse('for (;;)')}
|
1418
|
+
assert_raises(C::ParseError){C::And.parse('goto')}
|
1419
|
+
assert_raises(C::ParseError){C::And.parse('return')}
|
1420
1420
|
end
|
1421
1421
|
|
1422
1422
|
def test_or
|
@@ -1429,15 +1429,15 @@ Or
|
|
1429
1429
|
expr2: IntLiteral
|
1430
1430
|
val: 10
|
1431
1431
|
EOS
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1432
|
+
assert_raises(C::ParseError){C::Or.parse('} void f() {')}
|
1433
|
+
assert_raises(C::ParseError){C::Or.parse(';')}
|
1434
|
+
assert_raises(C::ParseError){C::Or.parse('int i')}
|
1435
|
+
assert_raises(C::ParseError){C::Or.parse('int')}
|
1436
|
+
assert_raises(C::ParseError){C::Or.parse('if (0)')}
|
1437
|
+
assert_raises(C::ParseError){C::Or.parse('switch (0)')}
|
1438
|
+
assert_raises(C::ParseError){C::Or.parse('for (;;)')}
|
1439
|
+
assert_raises(C::ParseError){C::Or.parse('goto')}
|
1440
|
+
assert_raises(C::ParseError){C::Or.parse('return')}
|
1441
1441
|
end
|
1442
1442
|
|
1443
1443
|
def test_not
|
@@ -1448,15 +1448,15 @@ Not
|
|
1448
1448
|
expr: Variable
|
1449
1449
|
name: "i"
|
1450
1450
|
EOS
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1451
|
+
assert_raises(C::ParseError){C::Not.parse('} void f() {')}
|
1452
|
+
assert_raises(C::ParseError){C::Not.parse(';')}
|
1453
|
+
assert_raises(C::ParseError){C::Not.parse('int i')}
|
1454
|
+
assert_raises(C::ParseError){C::Not.parse('int')}
|
1455
|
+
assert_raises(C::ParseError){C::Not.parse('if (0)')}
|
1456
|
+
assert_raises(C::ParseError){C::Not.parse('switch (0)')}
|
1457
|
+
assert_raises(C::ParseError){C::Not.parse('for (;;)')}
|
1458
|
+
assert_raises(C::ParseError){C::Not.parse('goto')}
|
1459
|
+
assert_raises(C::ParseError){C::Not.parse('return')}
|
1460
1460
|
end
|
1461
1461
|
|
1462
1462
|
def test_assign
|
@@ -1469,15 +1469,15 @@ Assign
|
|
1469
1469
|
rval: IntLiteral
|
1470
1470
|
val: 10
|
1471
1471
|
EOS
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1472
|
+
assert_raises(C::ParseError){C::Assign.parse('} void f() {')}
|
1473
|
+
assert_raises(C::ParseError){C::Assign.parse(';')}
|
1474
|
+
assert_raises(C::ParseError){C::Assign.parse('int i')}
|
1475
|
+
assert_raises(C::ParseError){C::Assign.parse('int')}
|
1476
|
+
assert_raises(C::ParseError){C::Assign.parse('if (0)')}
|
1477
|
+
assert_raises(C::ParseError){C::Assign.parse('switch (0)')}
|
1478
|
+
assert_raises(C::ParseError){C::Assign.parse('for (;;)')}
|
1479
|
+
assert_raises(C::ParseError){C::Assign.parse('goto')}
|
1480
|
+
assert_raises(C::ParseError){C::Assign.parse('return')}
|
1481
1481
|
end
|
1482
1482
|
|
1483
1483
|
def test_multiply_assign
|
@@ -1490,15 +1490,15 @@ MultiplyAssign
|
|
1490
1490
|
rval: IntLiteral
|
1491
1491
|
val: 10
|
1492
1492
|
EOS
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1493
|
+
assert_raises(C::ParseError){C::MultiplyAssign.parse('} void f() {')}
|
1494
|
+
assert_raises(C::ParseError){C::MultiplyAssign.parse(';')}
|
1495
|
+
assert_raises(C::ParseError){C::MultiplyAssign.parse('int i')}
|
1496
|
+
assert_raises(C::ParseError){C::MultiplyAssign.parse('int')}
|
1497
|
+
assert_raises(C::ParseError){C::MultiplyAssign.parse('if (0)')}
|
1498
|
+
assert_raises(C::ParseError){C::MultiplyAssign.parse('switch (0)')}
|
1499
|
+
assert_raises(C::ParseError){C::MultiplyAssign.parse('for (;;)')}
|
1500
|
+
assert_raises(C::ParseError){C::MultiplyAssign.parse('goto')}
|
1501
|
+
assert_raises(C::ParseError){C::MultiplyAssign.parse('return')}
|
1502
1502
|
end
|
1503
1503
|
|
1504
1504
|
def test_divide_assign
|
@@ -1511,15 +1511,15 @@ DivideAssign
|
|
1511
1511
|
rval: IntLiteral
|
1512
1512
|
val: 10
|
1513
1513
|
EOS
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1514
|
+
assert_raises(C::ParseError){C::DivideAssign.parse('} void f() {')}
|
1515
|
+
assert_raises(C::ParseError){C::DivideAssign.parse(';')}
|
1516
|
+
assert_raises(C::ParseError){C::DivideAssign.parse('int i')}
|
1517
|
+
assert_raises(C::ParseError){C::DivideAssign.parse('int')}
|
1518
|
+
assert_raises(C::ParseError){C::DivideAssign.parse('if (0)')}
|
1519
|
+
assert_raises(C::ParseError){C::DivideAssign.parse('switch (0)')}
|
1520
|
+
assert_raises(C::ParseError){C::DivideAssign.parse('for (;;)')}
|
1521
|
+
assert_raises(C::ParseError){C::DivideAssign.parse('goto')}
|
1522
|
+
assert_raises(C::ParseError){C::DivideAssign.parse('return')}
|
1523
1523
|
end
|
1524
1524
|
|
1525
1525
|
def test_mod_assign
|
@@ -1532,15 +1532,15 @@ ModAssign
|
|
1532
1532
|
rval: IntLiteral
|
1533
1533
|
val: 10
|
1534
1534
|
EOS
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1535
|
+
assert_raises(C::ParseError){C::ModAssign.parse('} void f() {')}
|
1536
|
+
assert_raises(C::ParseError){C::ModAssign.parse(';')}
|
1537
|
+
assert_raises(C::ParseError){C::ModAssign.parse('int i')}
|
1538
|
+
assert_raises(C::ParseError){C::ModAssign.parse('int')}
|
1539
|
+
assert_raises(C::ParseError){C::ModAssign.parse('if (0)')}
|
1540
|
+
assert_raises(C::ParseError){C::ModAssign.parse('switch (0)')}
|
1541
|
+
assert_raises(C::ParseError){C::ModAssign.parse('for (;;)')}
|
1542
|
+
assert_raises(C::ParseError){C::ModAssign.parse('goto')}
|
1543
|
+
assert_raises(C::ParseError){C::ModAssign.parse('return')}
|
1544
1544
|
end
|
1545
1545
|
|
1546
1546
|
def test_add_assign
|
@@ -1553,15 +1553,15 @@ AddAssign
|
|
1553
1553
|
rval: IntLiteral
|
1554
1554
|
val: 10
|
1555
1555
|
EOS
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1556
|
+
assert_raises(C::ParseError){C::AddAssign.parse('} void f() {')}
|
1557
|
+
assert_raises(C::ParseError){C::AddAssign.parse(';')}
|
1558
|
+
assert_raises(C::ParseError){C::AddAssign.parse('int i')}
|
1559
|
+
assert_raises(C::ParseError){C::AddAssign.parse('int')}
|
1560
|
+
assert_raises(C::ParseError){C::AddAssign.parse('if (0)')}
|
1561
|
+
assert_raises(C::ParseError){C::AddAssign.parse('switch (0)')}
|
1562
|
+
assert_raises(C::ParseError){C::AddAssign.parse('for (;;)')}
|
1563
|
+
assert_raises(C::ParseError){C::AddAssign.parse('goto')}
|
1564
|
+
assert_raises(C::ParseError){C::AddAssign.parse('return')}
|
1565
1565
|
end
|
1566
1566
|
|
1567
1567
|
def test_subtract_assign
|
@@ -1574,15 +1574,15 @@ SubtractAssign
|
|
1574
1574
|
rval: IntLiteral
|
1575
1575
|
val: 10
|
1576
1576
|
EOS
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1577
|
+
assert_raises(C::ParseError){C::SubtractAssign.parse('} void f() {')}
|
1578
|
+
assert_raises(C::ParseError){C::SubtractAssign.parse(';')}
|
1579
|
+
assert_raises(C::ParseError){C::SubtractAssign.parse('int i')}
|
1580
|
+
assert_raises(C::ParseError){C::SubtractAssign.parse('int')}
|
1581
|
+
assert_raises(C::ParseError){C::SubtractAssign.parse('if (0)')}
|
1582
|
+
assert_raises(C::ParseError){C::SubtractAssign.parse('switch (0)')}
|
1583
|
+
assert_raises(C::ParseError){C::SubtractAssign.parse('for (;;)')}
|
1584
|
+
assert_raises(C::ParseError){C::SubtractAssign.parse('goto')}
|
1585
|
+
assert_raises(C::ParseError){C::SubtractAssign.parse('return')}
|
1586
1586
|
end
|
1587
1587
|
|
1588
1588
|
def test_shift_left_assign
|
@@ -1595,15 +1595,15 @@ ShiftLeftAssign
|
|
1595
1595
|
rval: IntLiteral
|
1596
1596
|
val: 10
|
1597
1597
|
EOS
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1598
|
+
assert_raises(C::ParseError){C::ShiftLeftAssign.parse('} void f() {')}
|
1599
|
+
assert_raises(C::ParseError){C::ShiftLeftAssign.parse(';')}
|
1600
|
+
assert_raises(C::ParseError){C::ShiftLeftAssign.parse('int i')}
|
1601
|
+
assert_raises(C::ParseError){C::ShiftLeftAssign.parse('int')}
|
1602
|
+
assert_raises(C::ParseError){C::ShiftLeftAssign.parse('if (0)')}
|
1603
|
+
assert_raises(C::ParseError){C::ShiftLeftAssign.parse('switch (0)')}
|
1604
|
+
assert_raises(C::ParseError){C::ShiftLeftAssign.parse('for (;;)')}
|
1605
|
+
assert_raises(C::ParseError){C::ShiftLeftAssign.parse('goto')}
|
1606
|
+
assert_raises(C::ParseError){C::ShiftLeftAssign.parse('return')}
|
1607
1607
|
end
|
1608
1608
|
|
1609
1609
|
def test_shift_right_assign
|
@@ -1616,15 +1616,15 @@ ShiftRightAssign
|
|
1616
1616
|
rval: IntLiteral
|
1617
1617
|
val: 10
|
1618
1618
|
EOS
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1619
|
+
assert_raises(C::ParseError){C::ShiftRightAssign.parse('} void f() {')}
|
1620
|
+
assert_raises(C::ParseError){C::ShiftRightAssign.parse(';')}
|
1621
|
+
assert_raises(C::ParseError){C::ShiftRightAssign.parse('int i')}
|
1622
|
+
assert_raises(C::ParseError){C::ShiftRightAssign.parse('int')}
|
1623
|
+
assert_raises(C::ParseError){C::ShiftRightAssign.parse('if (0)')}
|
1624
|
+
assert_raises(C::ParseError){C::ShiftRightAssign.parse('switch (0)')}
|
1625
|
+
assert_raises(C::ParseError){C::ShiftRightAssign.parse('for (;;)')}
|
1626
|
+
assert_raises(C::ParseError){C::ShiftRightAssign.parse('goto')}
|
1627
|
+
assert_raises(C::ParseError){C::ShiftRightAssign.parse('return')}
|
1628
1628
|
end
|
1629
1629
|
|
1630
1630
|
def test_bit_and_assign
|
@@ -1637,15 +1637,15 @@ BitAndAssign
|
|
1637
1637
|
rval: IntLiteral
|
1638
1638
|
val: 10
|
1639
1639
|
EOS
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1640
|
+
assert_raises(C::ParseError){C::BitAndAssign.parse('} void f() {')}
|
1641
|
+
assert_raises(C::ParseError){C::BitAndAssign.parse(';')}
|
1642
|
+
assert_raises(C::ParseError){C::BitAndAssign.parse('int i')}
|
1643
|
+
assert_raises(C::ParseError){C::BitAndAssign.parse('int')}
|
1644
|
+
assert_raises(C::ParseError){C::BitAndAssign.parse('if (0)')}
|
1645
|
+
assert_raises(C::ParseError){C::BitAndAssign.parse('switch (0)')}
|
1646
|
+
assert_raises(C::ParseError){C::BitAndAssign.parse('for (;;)')}
|
1647
|
+
assert_raises(C::ParseError){C::BitAndAssign.parse('goto')}
|
1648
|
+
assert_raises(C::ParseError){C::BitAndAssign.parse('return')}
|
1649
1649
|
end
|
1650
1650
|
|
1651
1651
|
def test_bit_xor_assign
|
@@ -1658,15 +1658,15 @@ BitXorAssign
|
|
1658
1658
|
rval: IntLiteral
|
1659
1659
|
val: 10
|
1660
1660
|
EOS
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1661
|
+
assert_raises(C::ParseError){C::BitXorAssign.parse('} void f() {')}
|
1662
|
+
assert_raises(C::ParseError){C::BitXorAssign.parse(';')}
|
1663
|
+
assert_raises(C::ParseError){C::BitXorAssign.parse('int i')}
|
1664
|
+
assert_raises(C::ParseError){C::BitXorAssign.parse('int')}
|
1665
|
+
assert_raises(C::ParseError){C::BitXorAssign.parse('if (0)')}
|
1666
|
+
assert_raises(C::ParseError){C::BitXorAssign.parse('switch (0)')}
|
1667
|
+
assert_raises(C::ParseError){C::BitXorAssign.parse('for (;;)')}
|
1668
|
+
assert_raises(C::ParseError){C::BitXorAssign.parse('goto')}
|
1669
|
+
assert_raises(C::ParseError){C::BitXorAssign.parse('return')}
|
1670
1670
|
end
|
1671
1671
|
|
1672
1672
|
def test_bit_or_assign
|
@@ -1679,15 +1679,15 @@ BitOrAssign
|
|
1679
1679
|
rval: IntLiteral
|
1680
1680
|
val: 10
|
1681
1681
|
EOS
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1682
|
+
assert_raises(C::ParseError){C::BitOrAssign.parse('} void f() {')}
|
1683
|
+
assert_raises(C::ParseError){C::BitOrAssign.parse(';')}
|
1684
|
+
assert_raises(C::ParseError){C::BitOrAssign.parse('int i')}
|
1685
|
+
assert_raises(C::ParseError){C::BitOrAssign.parse('int')}
|
1686
|
+
assert_raises(C::ParseError){C::BitOrAssign.parse('if (0)')}
|
1687
|
+
assert_raises(C::ParseError){C::BitOrAssign.parse('switch (0)')}
|
1688
|
+
assert_raises(C::ParseError){C::BitOrAssign.parse('for (;;)')}
|
1689
|
+
assert_raises(C::ParseError){C::BitOrAssign.parse('goto')}
|
1690
|
+
assert_raises(C::ParseError){C::BitOrAssign.parse('return')}
|
1691
1691
|
end
|
1692
1692
|
|
1693
1693
|
def test_pointer
|
@@ -1703,9 +1703,9 @@ const volatile unsigned int*
|
|
1703
1703
|
Pointer
|
1704
1704
|
type: Int (const volatile unsigned)
|
1705
1705
|
EOS
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1706
|
+
assert_raises(C::ParseError){C::Pointer.parse('1);} void f() {(int')}
|
1707
|
+
assert_raises(C::ParseError){C::Pointer.parse('1); (int')}
|
1708
|
+
assert_raises(C::ParseError){C::Pointer.parse('void')}
|
1709
1709
|
end
|
1710
1710
|
|
1711
1711
|
def test_array
|
@@ -1723,9 +1723,9 @@ Array
|
|
1723
1723
|
length: IntLiteral
|
1724
1724
|
val: 10
|
1725
1725
|
EOS
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1726
|
+
assert_raises(C::ParseError){C::Array.parse('1);} void f() {(int')}
|
1727
|
+
assert_raises(C::ParseError){C::Array.parse('1); (int')}
|
1728
|
+
assert_raises(C::ParseError){C::Array.parse('void')}
|
1729
1729
|
end
|
1730
1730
|
|
1731
1731
|
def test_function
|
@@ -1748,9 +1748,9 @@ Function
|
|
1748
1748
|
type: Int
|
1749
1749
|
name: "y"
|
1750
1750
|
EOS
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1751
|
+
assert_raises(C::ParseError){C::Function.parse('1);} void f() {(int')}
|
1752
|
+
assert_raises(C::ParseError){C::Function.parse('1); (int')}
|
1753
|
+
assert_raises(C::ParseError){C::Function.parse('void')}
|
1754
1754
|
end
|
1755
1755
|
|
1756
1756
|
def test_struct
|
@@ -1775,9 +1775,9 @@ Struct (const)
|
|
1775
1775
|
num_bits: IntLiteral
|
1776
1776
|
val: 4
|
1777
1777
|
EOS
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1778
|
+
assert_raises(C::ParseError){C::Struct.parse('1);} void f() {(int')}
|
1779
|
+
assert_raises(C::ParseError){C::Struct.parse('1); (int')}
|
1780
|
+
assert_raises(C::ParseError){C::Struct.parse('void')}
|
1781
1781
|
end
|
1782
1782
|
|
1783
1783
|
def test_union
|
@@ -1802,9 +1802,9 @@ Union (const)
|
|
1802
1802
|
num_bits: IntLiteral
|
1803
1803
|
val: 4
|
1804
1804
|
EOS
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1805
|
+
assert_raises(C::ParseError){C::Union.parse('1);} void f() {(int')}
|
1806
|
+
assert_raises(C::ParseError){C::Union.parse('1); (int')}
|
1807
|
+
assert_raises(C::ParseError){C::Union.parse('void')}
|
1808
1808
|
end
|
1809
1809
|
|
1810
1810
|
def test_enum
|
@@ -1828,15 +1828,15 @@ Enum (const)
|
|
1828
1828
|
- Enumerator
|
1829
1829
|
name: "Z"
|
1830
1830
|
EOS
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1831
|
+
assert_raises(C::ParseError){C::Enum.parse('1);} void f() {(int')}
|
1832
|
+
assert_raises(C::ParseError){C::Enum.parse('1); (int')}
|
1833
|
+
assert_raises(C::ParseError){C::Enum.parse('void')}
|
1834
1834
|
end
|
1835
1835
|
|
1836
1836
|
def test_custom_type
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1837
|
+
assert_raises(C::ParseError){C::CustomType.parse('1);} void f() {(int')}
|
1838
|
+
assert_raises(C::ParseError){C::CustomType.parse('1); (int')}
|
1839
|
+
assert_raises(C::ParseError){C::CustomType.parse('void')}
|
1840
1840
|
end
|
1841
1841
|
|
1842
1842
|
def test_void
|
@@ -1845,9 +1845,9 @@ const void
|
|
1845
1845
|
----
|
1846
1846
|
Void (const)
|
1847
1847
|
EOS
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1848
|
+
assert_raises(C::ParseError){C::Void.parse('1);} void f() {(int')}
|
1849
|
+
assert_raises(C::ParseError){C::Void.parse('1); (int')}
|
1850
|
+
assert_raises(C::ParseError){C::Void.parse('int')}
|
1851
1851
|
end
|
1852
1852
|
|
1853
1853
|
def test_int
|
@@ -1856,9 +1856,9 @@ const int
|
|
1856
1856
|
----
|
1857
1857
|
Int (const)
|
1858
1858
|
EOS
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1859
|
+
assert_raises(C::ParseError){C::Int.parse('1);} void f() {(int')}
|
1860
|
+
assert_raises(C::ParseError){C::Int.parse('1); (int')}
|
1861
|
+
assert_raises(C::ParseError){C::Int.parse('void')}
|
1862
1862
|
end
|
1863
1863
|
|
1864
1864
|
def test_float
|
@@ -1867,9 +1867,9 @@ const float
|
|
1867
1867
|
----
|
1868
1868
|
Float (const)
|
1869
1869
|
EOS
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1870
|
+
assert_raises(C::ParseError){C::Float.parse('1);} void f() {(int')}
|
1871
|
+
assert_raises(C::ParseError){C::Float.parse('1); (int')}
|
1872
|
+
assert_raises(C::ParseError){C::Float.parse('void')}
|
1873
1873
|
end
|
1874
1874
|
|
1875
1875
|
def test_char
|
@@ -1878,9 +1878,9 @@ const char
|
|
1878
1878
|
----
|
1879
1879
|
Char (const)
|
1880
1880
|
EOS
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1881
|
+
assert_raises(C::ParseError){C::Char.parse('1);} void f() {(int')}
|
1882
|
+
assert_raises(C::ParseError){C::Char.parse('1); (int')}
|
1883
|
+
assert_raises(C::ParseError){C::Char.parse('void')}
|
1884
1884
|
end
|
1885
1885
|
|
1886
1886
|
def test_bool
|
@@ -1889,9 +1889,9 @@ const _Bool
|
|
1889
1889
|
----
|
1890
1890
|
Bool (const)
|
1891
1891
|
EOS
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1892
|
+
assert_raises(C::ParseError){C::Bool.parse('1);} void f() {(int')}
|
1893
|
+
assert_raises(C::ParseError){C::Bool.parse('1); (int')}
|
1894
|
+
assert_raises(C::ParseError){C::Bool.parse('void')}
|
1895
1895
|
end
|
1896
1896
|
|
1897
1897
|
def test_complex
|
@@ -1900,9 +1900,9 @@ const _Complex float
|
|
1900
1900
|
----
|
1901
1901
|
Complex (const)
|
1902
1902
|
EOS
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1903
|
+
assert_raises(C::ParseError){C::Complex.parse('1);} void f() {(int')}
|
1904
|
+
assert_raises(C::ParseError){C::Complex.parse('1); (int')}
|
1905
|
+
assert_raises(C::ParseError){C::Complex.parse('void')}
|
1906
1906
|
end
|
1907
1907
|
|
1908
1908
|
def test_imaginary
|
@@ -1911,9 +1911,9 @@ const _Imaginary float
|
|
1911
1911
|
----
|
1912
1912
|
Imaginary (const)
|
1913
1913
|
EOS
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1914
|
+
assert_raises(C::ParseError){C::Imaginary.parse('1);} void f() {(int')}
|
1915
|
+
assert_raises(C::ParseError){C::Imaginary.parse('1); (int')}
|
1916
|
+
assert_raises(C::ParseError){C::Imaginary.parse('void')}
|
1917
1917
|
end
|
1918
1918
|
|
1919
1919
|
def test_string_literal
|
@@ -1923,15 +1923,15 @@ EOS
|
|
1923
1923
|
StringLiteral
|
1924
1924
|
val: "hello"
|
1925
1925
|
EOS
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1926
|
+
assert_raises(C::ParseError){C::StringLiteral.parse('} void f() {')}
|
1927
|
+
assert_raises(C::ParseError){C::StringLiteral.parse(';')}
|
1928
|
+
assert_raises(C::ParseError){C::StringLiteral.parse('int i')}
|
1929
|
+
assert_raises(C::ParseError){C::StringLiteral.parse('int')}
|
1930
|
+
assert_raises(C::ParseError){C::StringLiteral.parse('if (0)')}
|
1931
|
+
assert_raises(C::ParseError){C::StringLiteral.parse('switch (0)')}
|
1932
|
+
assert_raises(C::ParseError){C::StringLiteral.parse('for (;;)')}
|
1933
|
+
assert_raises(C::ParseError){C::StringLiteral.parse('goto')}
|
1934
|
+
assert_raises(C::ParseError){C::StringLiteral.parse('return')}
|
1935
1935
|
end
|
1936
1936
|
|
1937
1937
|
def test_string_literal_concatenation
|
@@ -1950,15 +1950,15 @@ EOS
|
|
1950
1950
|
CharLiteral
|
1951
1951
|
val: "x"
|
1952
1952
|
EOS
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1953
|
+
assert_raises(C::ParseError){C::CharLiteral.parse('} void f() {')}
|
1954
|
+
assert_raises(C::ParseError){C::CharLiteral.parse(';')}
|
1955
|
+
assert_raises(C::ParseError){C::CharLiteral.parse('int i')}
|
1956
|
+
assert_raises(C::ParseError){C::CharLiteral.parse('int')}
|
1957
|
+
assert_raises(C::ParseError){C::CharLiteral.parse('if (0)')}
|
1958
|
+
assert_raises(C::ParseError){C::CharLiteral.parse('switch (0)')}
|
1959
|
+
assert_raises(C::ParseError){C::CharLiteral.parse('for (;;)')}
|
1960
|
+
assert_raises(C::ParseError){C::CharLiteral.parse('goto')}
|
1961
|
+
assert_raises(C::ParseError){C::CharLiteral.parse('return')}
|
1962
1962
|
end
|
1963
1963
|
|
1964
1964
|
def test_compound_literal
|
@@ -1999,15 +1999,15 @@ CompoundLiteral
|
|
1999
1999
|
init: IntLiteral
|
2000
2000
|
val: 2
|
2001
2001
|
EOS
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2002
|
+
assert_raises(C::ParseError){C::CompoundLiteral.parse('} void f() {')}
|
2003
|
+
assert_raises(C::ParseError){C::CompoundLiteral.parse(';')}
|
2004
|
+
assert_raises(C::ParseError){C::CompoundLiteral.parse('int i')}
|
2005
|
+
assert_raises(C::ParseError){C::CompoundLiteral.parse('int')}
|
2006
|
+
assert_raises(C::ParseError){C::CompoundLiteral.parse('if (0)')}
|
2007
|
+
assert_raises(C::ParseError){C::CompoundLiteral.parse('switch (0)')}
|
2008
|
+
assert_raises(C::ParseError){C::CompoundLiteral.parse('for (;;)')}
|
2009
|
+
assert_raises(C::ParseError){C::CompoundLiteral.parse('goto')}
|
2010
|
+
assert_raises(C::ParseError){C::CompoundLiteral.parse('return')}
|
2011
2011
|
end
|
2012
2012
|
|
2013
2013
|
def test_int_literal
|
@@ -2017,15 +2017,15 @@ EOS
|
|
2017
2017
|
IntLiteral
|
2018
2018
|
val: 1
|
2019
2019
|
EOS
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2020
|
+
assert_raises(C::ParseError){C::IntLiteral.parse('} void f() {')}
|
2021
|
+
assert_raises(C::ParseError){C::IntLiteral.parse(';')}
|
2022
|
+
assert_raises(C::ParseError){C::IntLiteral.parse('int i')}
|
2023
|
+
assert_raises(C::ParseError){C::IntLiteral.parse('int')}
|
2024
|
+
assert_raises(C::ParseError){C::IntLiteral.parse('if (0)')}
|
2025
|
+
assert_raises(C::ParseError){C::IntLiteral.parse('switch (0)')}
|
2026
|
+
assert_raises(C::ParseError){C::IntLiteral.parse('for (;;)')}
|
2027
|
+
assert_raises(C::ParseError){C::IntLiteral.parse('goto')}
|
2028
|
+
assert_raises(C::ParseError){C::IntLiteral.parse('return')}
|
2029
2029
|
end
|
2030
2030
|
|
2031
2031
|
def test_float_literal
|
@@ -2035,15 +2035,15 @@ EOS
|
|
2035
2035
|
FloatLiteral
|
2036
2036
|
val: 1.0
|
2037
2037
|
EOS
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2038
|
+
assert_raises(C::ParseError){C::FloatLiteral.parse('} void f() {')}
|
2039
|
+
assert_raises(C::ParseError){C::FloatLiteral.parse(';')}
|
2040
|
+
assert_raises(C::ParseError){C::FloatLiteral.parse('int i')}
|
2041
|
+
assert_raises(C::ParseError){C::FloatLiteral.parse('int')}
|
2042
|
+
assert_raises(C::ParseError){C::FloatLiteral.parse('if (0)')}
|
2043
|
+
assert_raises(C::ParseError){C::FloatLiteral.parse('switch (0)')}
|
2044
|
+
assert_raises(C::ParseError){C::FloatLiteral.parse('for (;;)')}
|
2045
|
+
assert_raises(C::ParseError){C::FloatLiteral.parse('goto')}
|
2046
|
+
assert_raises(C::ParseError){C::FloatLiteral.parse('return')}
|
2047
2047
|
end
|
2048
2048
|
|
2049
2049
|
def test_variable
|
@@ -2053,14 +2053,14 @@ x
|
|
2053
2053
|
Variable
|
2054
2054
|
name: "x"
|
2055
2055
|
EOS
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2056
|
+
assert_raises(C::ParseError){C::Variable.parse('} void f() {')}
|
2057
|
+
assert_raises(C::ParseError){C::Variable.parse(';')}
|
2058
|
+
assert_raises(C::ParseError){C::Variable.parse('int i')}
|
2059
|
+
assert_raises(C::ParseError){C::Variable.parse('int')}
|
2060
|
+
assert_raises(C::ParseError){C::Variable.parse('if (0)')}
|
2061
|
+
assert_raises(C::ParseError){C::Variable.parse('switch (0)')}
|
2062
|
+
assert_raises(C::ParseError){C::Variable.parse('for (;;)')}
|
2063
|
+
assert_raises(C::ParseError){C::Variable.parse('goto')}
|
2064
|
+
assert_raises(C::ParseError){C::Variable.parse('return')}
|
2065
2065
|
end
|
2066
2066
|
end
|