Top Level Namespace
Defined Under Namespace
Modules: NexusParser
Instance Method Summary collapse
Instance Method Details
#parse_nexus_file(input) ⇒ Object
269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/nexus_parser.rb', line 269 def parse_nexus_file(input) @input = input @input.gsub!(/\[[^\]]*\]/,'') # strip out all comments BEFORE we parse the file # quickly peek at the input, does this look like a Nexus file? if !(@input =~ /\#Nexus/i) || !(@input =~ /Begin/i) || !(@input =~ /Matrix/i) || !(@input =~ /(end|endblock)\;/i) raise(NexusParser::ParseError, "File is missing at least some required headers, check formatting.", caller) end builder = NexusParser::Builder.new lexer = NexusParser::Lexer.new(@input) NexusParser::Parser.new(lexer, builder).parse_file return builder.nexus_file end |