~ubuntu-branches/ubuntu/intrepid/racc/intrepid

« back to all changes in this revision

Viewing changes to packages/racc/test/err.y

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2005-04-09 17:54:44 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050409175444-fvtir838ypkn7a58
Tags: 1.4.4-1
* new upstream version.  (closes: #301768)
* added racc2y.1 and y2racc.1.
* modified racc2y and y2racc to use optparse instead of deprecated getopts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
class ErrTestp
 
3
 
 
4
rule
 
5
 
 
6
target: lines
 
7
      ;
 
8
 
 
9
lines: line
 
10
     | lines line
 
11
     ;
 
12
 
 
13
line: A B C D E
 
14
    | error E
 
15
    ;
 
16
 
 
17
end
 
18
 
 
19
---- inner
 
20
 
 
21
def initialize
 
22
  @yydebug = false
 
23
  @q = [
 
24
    [:A, 'a'],
 
25
    # [:B, 'b'],
 
26
    [:C, 'c'],
 
27
    [:D, 'd'],
 
28
    [:E, 'e'],
 
29
 
 
30
    [:A, 'a'],
 
31
    [:B, 'b'],
 
32
    [:C, 'c'],
 
33
    [:D, 'd'],
 
34
    [:E, 'e'],
 
35
 
 
36
    [:A, 'a'],
 
37
    [:B, 'b'],
 
38
    # [:C, 'c'],
 
39
    [:D, 'd'],
 
40
    [:E, 'e'],
 
41
    [false, nil]
 
42
  ]
 
43
end
 
44
 
 
45
def next_token
 
46
  @q.shift
 
47
end
 
48
 
 
49
def on_error( t, val, values )
 
50
  $stderr.puts "error on token '#{val}'(#{t})"
 
51
end
 
52
 
 
53
def parse
 
54
  do_parse
 
55
end
 
56
 
 
57
---- footer
 
58
 
 
59
p = ErrTestp.new
 
60
p.parse