lib/ebnf/ll1.rb in ebnf-2.0.0 vs lib/ebnf/ll1.rb in ebnf-2.1.0

- old
+ new

@@ -7,13 +7,11 @@ # The Branch table is a hash mapping production rules to a hash relating terminals appearing in input to sequence of productions to follow when the corresponding input terminal is found. This allows either the `seq` primitive, where all terminals map to the same sequence of productions, or the `alt` primitive, where each terminal may map to a different production. # # BRANCH = { # :alt => { # "(" => [:seq, :_alt_1], - # :ENUM => [:seq, :_alt_1], # :HEX => [:seq, :_alt_1], - # :O_ENUM => [:seq, :_alt_1], # :O_RANGE => [:seq, :_alt_1], # :RANGE => [:seq, :_alt_1], # :STRING1 => [:seq, :_alt_1], # :STRING2 => [:seq, :_alt_1], # :SYMBOL => [:seq, :_alt_1], @@ -36,12 +34,10 @@ # # FIRST = { # :alt => [ # :HEX, # :SYMBOL, - # :ENUM, - # :O_ENUM, # :RANGE, # :O_RANGE, # :STRING1, # :STRING2, # "("], @@ -52,11 +48,11 @@ # # This table is a simple list of the terminal productions found in the grammar. For example: # # TERMINALS = ["(", ")", "-", # "@pass", "@terminals", - # :ENUM, :HEX, :LHS, :O_ENUM, :O_RANGE,:POSTFIX, + # :HEX, :LHS, :O_RANGE,:POSTFIX, # :RANGE, :STRING1, :STRING2, :SYMBOL,"|" # ].freeze # ### Cleanup Table # @@ -212,11 +208,12 @@ ittr = 0 begin firsts, follows = 0, 0 # add Fi(wi) to Fi(Ai) for every rule Ai → wi # - # For sequences, this is the first rule in the sequence. - # For alts, this is every rule in the sequence + # * For sequences, this is the first rule in the sequence. + # * For alts, this is every rule in the sequence + # * Other rules don't matter, as they don't appear in strict BNF each(:rule) do |ai| # Fi(a w' ) = { a } for every terminal a ai.terminals(ast).each do |t| debug("Fi.2.1") {"(#{ittr}) add terminal #{t} to #{ai.sym}"} firsts += ai.add_first([t])