Permalink
Browse files

handles link lines

  • Loading branch information...
1 parent d68d76a commit 21be8444460400541f772a2a952a0faed52380b8 @mjy committed Apr 13, 2011
Showing with 17 additions and 3 deletions.
  1. +0 −2 lib/nexus_parser.rb
  2. +3 −1 lib/parser.rb
  3. +5 −0 lib/tokens.rb
  4. +9 −0 test/test_nexus_parser.rb
View
@@ -162,12 +162,10 @@ def add_var(hash)
end
def update_taxon(options = {})
-
@opt = {
:name => ''
}.merge!(options)
return false if !@opt[:index]
-
(@nf.taxa[@opt[:index]].name = @opt[:name]) if @opt[:name]
end
View
@@ -127,7 +127,8 @@ def parse_characters_blk
break
else
@lexer.pop(NexusParser::Tokens::Title) if @lexer.peek(NexusParser::Tokens::Title) # not used at present
-
+ @lexer.pop(NexusParser::Tokens::LinkLine) if @lexer.peek(NexusParser::Tokens::LinkLine) # trashing these for now
+
parse_dimensions if @lexer.peek(NexusParser::Tokens::Dimensions)
parse_format if @lexer.peek(NexusParser::Tokens::Format)
@@ -137,6 +138,7 @@ def parse_characters_blk
# handle "\s*OPTIONS MSTAXA = UNCERTAIN;\s\n" within a characters block (sticks in an infinite loop right now)
+
@lexer.pop(NexusParser::Tokens::MesquiteIDs) if @lexer.peek(NexusParser::Tokens::MesquiteIDs) # trashing these for now
@lexer.pop(NexusParser::Tokens::MesquiteBlockID) if @lexer.peek(NexusParser::Tokens::MesquiteBlockID) # trashing these for now
View
@@ -87,6 +87,10 @@ class ChrsBlk < Token
@regexp = Regexp.new(/\A\s*(characters\s*;)\s*/i)
end
+ class LinkLine < Token
+ @regexp = Regexp.new(/\A\s*(link.*\s*;)\s*\n*/i)
+ end
+
# note we grab EOL and ; here
class ValuePair < Token
@regexp = Regexp.new(/\A\s*([\w\d\_\&]+\s*=\s*((\'[^\']+\')|(\(.*\))|(\"[^\"]+\")|([^\s\n\t;]+)))[\s\n\t;]+/i) # returns key => value hash for tokens like 'foo=bar' or foo = 'b a ar'
@@ -261,6 +265,7 @@ def self.nexus_file_token_list
NexusParser::Tokens::RBracket,
NexusParser::Tokens::Label, # must be before RowVec
NexusParser::Tokens::RowVec,
+ NexusParser::Tokens::LinkLine,
NexusParser::Tokens::ID # need to trash this
]
end
@@ -930,5 +930,14 @@ def DONT_test_misc
assert true, foo
end
+ def test_misc
+
+ assert nf = File.read(File.expand_path(File.join(File.dirname(__FILE__), '../test/Aptostichus.nex')) )
+ foo = parse_nexus_file(nf)
+ assert true, foo
+ end
+
+
+
end

0 comments on commit 21be844

Please sign in to comment.