Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access the following[] tokens from state? #14

Closed
talek opened this issue Jul 18, 2011 · 1 comment
Closed

How to access the following[] tokens from state? #14

talek opened this issue Jul 18, 2011 · 1 comment

Comments

@talek
Copy link

talek commented Jul 18, 2011

Hi,

Within a parser, Is it possible to know what are the available paths to follow from the current position? For example, I have the following very simple grammar:

grammar Simple;

options {
  language=Ruby;
  k='*';
  backtrack=true;
  memoize=true;
  output=AST;
}

simple
  :   
  SELECT { p @state } (ALL | FROM) 'DUAL'
  ;

SELECT: 'SELECT';
ALL: 'ALL';
FROM: 'FROM';

Then I use the following snippet:

require 'rubygems'
require 'antlr3'
require 'SimpleParser.rb'
require 'SimpleLexer.rb'

text = 'SELECT'
lexer = Simple::Lexer.new(text)
tokens = ANTLR3::CommonTokenStream.new(lexer)
parser = Simple::Parser.new(tokens)
parser.simple

Runing this I was hoping to get the following[] property of the @state with all the next possible paths to follow. Unfortunately, this property is always empty. Can you shed some light here? How this property is supposed to work?

Many thanks!

@talek
Copy link
Author

talek commented Oct 17, 2011

Meanwhile, I figured out how this array is filled in by looking into the code.

@talek talek closed this as completed Oct 17, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant