Sha256: 180d3b36904ba940be1e781096524082a1fedf64d744030595157a4c6a322d43
Contents?: true
Size: 1.43 KB
Versions: 4
Compression:
Stored size: 1.43 KB
Contents
class OboParser::Parser def initialize(lexer, builder) @lexer = lexer @builder = builder end def parse_file # At present we ignore the header lines while !@lexer.peek(OboParser::Tokens::Term) @lexer.pop(OboParser::Tokens::TagValuePair) end i = 0 while !@lexer.peek(OboParser::Tokens::Typedef) && !@lexer.peek(OboParser::Tokens::EndOfFile) raise OboParser::ParseError, "infinite loop in Terms" if i > 10000000 # there aren't that many words! parse_term i += 1 end i = 0 while @lexer.peek(OboParser::Tokens::Typedef) raise OboParser::ParseError,"infinite loop in Typedefs" if i > 1000000 parse_typedef i += 1 end end def parse_term t = @lexer.pop(OboParser::Tokens::Term) tags = [] while !@lexer.peek(OboParser::Tokens::Term) && !@lexer.peek(OboParser::Tokens::Typedef) && !@lexer.peek(OboParser::Tokens::EndOfFile) begin t = @lexer.pop(OboParser::Tokens::TagValuePair) tags.push(t) rescue raise end end @builder.add_term(tags) end def parse_typedef @lexer.pop(OboParser::Tokens::Typedef) tags = [] while !@lexer.peek(OboParser::Tokens::Typedef) && @lexer.peek(OboParser::Tokens::TagValuePair) begin t = @lexer.pop(OboParser::Tokens::TagValuePair) tags.push(t) rescue raise end end @builder.add_typedef(tags) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
obo_parser-0.3.3 | lib/parser.rb |
obo_parser-0.3.2 | lib/parser.rb |
obo_parser-0.3.1 | lib/parser.rb |
obo_parser-0.3.0 | lib/parser.rb |