• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package ANTLR::Runtime::TokenSource;
2
3use Moose::Role;
4
5# Return a Token object from your input stream (usually a CharStream).
6# Do not fail/return upon lexing error; keep chewing on the characters
7# until you get a good one; errors are not passed through to the parser.
8requires 'next_token';
9
10# Where are you getting tokens from? normally the implication will simply
11# ask lexers input stream.
12requires 'get_source_name';
13
14no Moose::Role;
151;
16__END__
17
18=head1 NAME
19
20ANTLR::Runtime::TokenSource
21
22=head1 DESCRIPTION
23
24A source of tokens must provide a sequence of tokens via nextToken()
25and also must reveal it's source of characters; CommonToken's text is
26computed from a CharStream; it only store indices into the char stream.
27
28Errors from the lexer are never passed to the parser.  Either you want
29to keep going or you do not upon token recognition error.  If you do not
30want to continue lexing then you do not want to continue parsing.  Just
31throw an exception not under RecognitionException and Java will naturally
32toss you all the way out of the recognizers.  If you want to continue
33lexing then you should not throw an exception to the parser--it has already
34requested a token.  Keep lexing until you get a valid one.  Just report
35errors and keep going, looking for a valid token.
36