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

« back to all changes in this revision

Viewing changes to packages/racc/lib/racc/grammarfileparser.rb.in

  • 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
# This file is automatically generated. DO NOT MODIFY!!
 
3
#
 
4
# grammerfileparser.rb
 
5
#
 
6
# Copyright (c) 1999-2003 Minero Aoki <aamine@loveruby.net>
 
7
#
 
8
# This program is free software.
 
9
# You can distribute/modify this program under the terms of
 
10
# the GNU LGPL, Lesser General Public License version 2.
 
11
# For details of the GNU LGPL, see the file "COPYING".
 
12
#
 
13
 
 
14
require 'racc/compat'
 
15
require 'racc/parser'
 
16
require 'racc/grammarfilescanner'
 
17
require 'racc/usercodeparser'
 
18
 
 
19
 
 
20
module Racc
 
21
 
 
22
  class GrammarFileParser < Parser
 
23
 
 
24
    def initialize( racc )
 
25
      @yydebug     = racc.d_parse && Racc_debug_parser
 
26
      @ruletable   = racc.ruletable
 
27
      @symboltable = racc.symboltable
 
28
 
 
29
      @class_name = nil
 
30
      @super_class = nil
 
31
    end
 
32
 
 
33
    attr_reader :class_name
 
34
    attr_reader :super_class
 
35
 
 
36
    def parse( str )
 
37
      @scanner = GrammarFileScanner.new(str)
 
38
      @scanner.debug = @yydebug
 
39
      do_parse
 
40
    end
 
41
 
 
42
    private
 
43
 
 
44
    def next_token
 
45
      @scanner.scan
 
46
    end
 
47
 
 
48
    def on_error( tok, val, _values )
 
49
      if val.respond_to?(:id2name)
 
50
        v = val.id2name
 
51
      elsif String === val
 
52
        v = val
 
53
      else
 
54
        v = val.inspect
 
55
      end
 
56
      raise ParseError, "#{@scanner.lineno}: unexpected token '#{v}'"
 
57
    end
 
58
 
 
59
    STATE_TRANSITION_TABLE
 
60
 
 
61
  end
 
62
 
 
63
end   # module Racc