aboutsummaryrefslogtreecommitdiff
path: root/antlr-3.4/runtime/Ruby/test/functional/lexer/nuances.rb
blob: 0666b466390b78dbbc5c550e851d3e0a102600b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/ruby
# encoding: utf-8

require 'antlr3/test/functional'

class TestBug80 < ANTLR3::Test::Functional
  inline_grammar( <<-'END' )
    lexer grammar Bug80;
    options { language = Ruby; }
     
    ID_LIKE
        : 'defined' 
        | {false}? Identifier 
        | Identifier 
        ; 
     
    fragment
    // with just 'a', output compiles
    Identifier: 'a'..'z'+ ;
  END
  
  example "um... something" do
    lexer = Bug80::Lexer.new( 'defined' )
    tokens = lexer.each { |tk| tk }
  end
end


class TestEOF < ANTLR3::Test::Functional

  inline_grammar( <<-'END' )
    lexer grammar EndOfFile;
    
    options {
      language = Ruby;
    }
    
    KEND: EOF;
    SPACE: ' ';
  END
  
  example 'referencing EOF in a rule' do
    lexer = EndOfFile::Lexer.new( " " )
    tks = lexer.map { |tk| tk }
  end
end