lib/rley/engine.rb in rley-0.6.00 vs lib/rley/engine.rb in rley-0.6.01

- old
+ new

@@ -20,15 +20,13 @@ class Engine attr_reader :configuration attr_reader :grammar # Constructor. - # @param &aBlock [Proc, Lambda] Code block for setting the configuration. - def initialize(&aConfigBlock) + def initialize() @configuration = EngineConfig.new - - yield configuration if block_given? + yield configuration if block_given? end # Factory method. # @param &aBlock [Proc, Lambda] Code block for creating the grammar. def build_grammar(&aBlock) @@ -46,16 +44,15 @@ # @param aTokenizer [#each] # @return [Parser::GFGParsing] def parse(aTokenizer) tokens = [] aTokenizer.each do |a_token| - if a_token - term_name = a_token.terminal - term_symb = grammar.name2symbol[term_name] - a_token.instance_variable_set(:@terminal, term_symb) - tokens << a_token - end + next unless a_token + term_name = a_token.terminal + term_symb = grammar.name2symbol[term_name] + a_token.instance_variable_set(:@terminal, term_symb) + tokens << a_token end parser = build_parser(grammar) return parser.parse(tokens) end @@ -87,18 +84,18 @@ end # Convert raw parse result into a parse forest representation # @param aRawParse [Parser::GFGParsing] # def to_pforest(aRawParse) - # factory = ParseRep::ParseForestFactory.new(aRawParse) - # if configuration.repr_builder == :default - # result = factory.create(nil) - # else - # result = factory.create(configuration.repr_builder) - # end + # factory = ParseRep::ParseForestFactory.new(aRawParse) + # if configuration.repr_builder == :default + # result = factory.create(nil) + # else + # result = factory.create(configuration.repr_builder) + # end - # return result + # return result # end # Build a visitor for the given parse tree # @param aPTree[PTree::ParseTree] # @return [ParseTreeVisitor] @@ -107,16 +104,15 @@ end # @param aPTree[SPPF::ParseForest] # @return [ParseForestVisitor] # def pforest_visitor(aPForest) - # return Rley::ParseForestVisitor.new(aPForest) + # return Rley::ParseForestVisitor.new(aPForest) # end protected def build_parser(aGrammar) return Parser::GFGEarleyParser.new(aGrammar) end end # class end # module -