Remove TOKEN_EOF; define EOF token and start rule in Generator
This commit is contained in:
1 parent
150be33826
commit
f46b5b3f4d
9 files changed
+59
-60
No files matched your search
+24
-7
@@ -2,13 +2,25 @@ class Propane
|
||||
|
||||
class Token
|
||||
|
||||
class << self
|
||||
|
||||
# Name of the token to use in code (special characters replaced).
|
||||
#
|
||||
# @return [String]
|
||||
# Name of the token to use in code (special characters replaced).
|
||||
def code_name(name)
|
||||
name.sub(/^\$/, "0")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# @return [String, nil]
|
||||
# Token name.
|
||||
attr_reader :name
|
||||
|
||||
# @return [Integer, nil]
|
||||
# Token ID.
|
||||
attr_reader :id
|
||||
attr_accessor :id
|
||||
|
||||
# @return [Integer, nil]
|
||||
# Line number where the token was defined in the input grammar.
|
||||
@@ -20,14 +32,19 @@ class Propane
|
||||
# Optional parameters.
|
||||
# @option options [String, nil] :name
|
||||
# Token name.
|
||||
# @option options [Integer, nil] :id
|
||||
# Token ID.
|
||||
# @option options [Integer, nil] :line_number
|
||||
# Line number where the token was defined in the input grammar.
|
||||
def initialize(options)
|
||||
@name = options[:name]
|
||||
@id = options[:id]
|
||||
@line_number = options[:line_number]
|
||||
def initialize(name, line_number)
|
||||
@name = name
|
||||
@line_number = line_number
|
||||
end
|
||||
|
||||
# Name of the token to use in code (special characters replaced).
|
||||
#
|
||||
# @return [String]
|
||||
# Name of the token to use in code (special characters replaced).
|
||||
def code_name
|
||||
self.class.code_name(@name)
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
||||
Reference in new issue
Block a user