Home | History | Annotate | Download | only in lexer
      1 #!/usr/bin/ruby
      2 # encoding: utf-8
      3 
      4 require 'antlr3/test/functional'
      5 
      6 class TestBug80 < ANTLR3::Test::Functional
      7   inline_grammar( <<-'END' )
      8     lexer grammar Bug80;
      9     options { language = Ruby; }
     10      
     11     ID_LIKE
     12         : 'defined' 
     13         | {false}? Identifier 
     14         | Identifier 
     15         ; 
     16      
     17     fragment
     18     // with just 'a', output compiles
     19     Identifier: 'a'..'z'+ ;
     20   END
     21   
     22   example "um... something" do
     23     lexer = Bug80::Lexer.new( 'defined' )
     24     tokens = lexer.each { |tk| tk }
     25   end
     26 end
     27 
     28 
     29 class TestEOF < ANTLR3::Test::Functional
     30 
     31   inline_grammar( <<-'END' )
     32     lexer grammar EndOfFile;
     33     
     34     options {
     35       language = Ruby;
     36     }
     37     
     38     KEND: EOF;
     39     SPACE: ' ';
     40   END
     41   
     42   example 'referencing EOF in a rule' do
     43     lexer = EndOfFile::Lexer.new( " " )
     44     tks = lexer.map { |tk| tk }
     45   end
     46 end
     47