lib/lrama/context.rb in lrama-0.5.2 vs lib/lrama/context.rb in lrama-0.5.3
- old
+ new
@@ -1,6 +1,6 @@
-require "lrama/report"
+require "lrama/report/duration"
module Lrama
# This is passed to a template
class Context
include Report::Duration
@@ -82,9 +82,19 @@
# 2 is YYSYMBOL_YYUNDEF
a = Array.new(yymaxutok, 2)
@states.terms.each do |term|
a[term.token_id] = term.number
+ end
+
+ return a
+ end
+
+ def yytranslate_inverted
+ a = Array.new(@states.symbols.count, @states.undef_symbol.token_id)
+
+ @states.terms.each do |term|
+ a[term.number] = term.token_id
end
return a
end