sdr 0.7

net.cscott.sdr.calls.parser
Class CallFileLexer

java.lang.Object
  extended by org.antlr.runtime.BaseRecognizer
      extended by org.antlr.runtime.Lexer
          extended by net.cscott.sdr.calls.parser.CallFileLexer
All Implemented Interfaces:
org.antlr.runtime.TokenSource
Direct Known Subclasses:
AstTokenTypes

public class CallFileLexer
extends org.antlr.runtime.Lexer


Nested Class Summary
static class CallFileLexer.IndentProcessor
          Inner class: a token stream filter to implement INDENT/DEDENT processing.
 
Field Summary
static int ADJ
           
static int AFTER
           
static int APPLY
           
static int ARG
           
static int ASSERT
           
static int ATTRIBS
           
static int BEFORE
           
static int BODY
           
static int CALL
           
static int CALLLIST
           
static int COLON
           
static int COMMA
           
static int COMMENT
           
static int CONDITION
           
static int DEDENT
           
static int DEF
           
protected  net.cscott.sdr.calls.parser.CallFileLexer.DFA14 dfa14
           
static int ENDS
           
static int EOF
           
static int EQUALS
           
static int EXAMPLE
           
static int EXPR
           
static int FIGURE
           
static int FROM
           
static int IDENT
           
static int IF
           
static int IN
           
static int INDENT
           
 CallFileLexer.IndentProcessor indentProcessor
           
static int INITIAL_WS
           
static int INTEGER
           
static int IPART
           
static int ITEM
           
static int LANGLE
           
static int LBRACK
           
static int LEFT
           
static int LPAREN
           
static int MINUS
           
static int NL
           
static int NONE
           
static int NUMBER
           
static int OPT
           
static int OPTIONAL
           
static int OUT
           
static int PAR
           
static int PART
           
static int PLUS
           
static int PRIM
           
static int PROGRAM
           
static int QUESTION
           
static int RANGLE
           
static int RBRACK
           
static int REF
           
static int RIGHT
           
static int RPAREN
           
static int SELECT
           
static int SEQ
           
static int SLASH
           
static int SPOKEN
           
static int STAR
           
static int VBAR
           
static int WS
           
static int WSNL
           
static int XPART
           
 
Fields inherited from class org.antlr.runtime.Lexer
input
 
Fields inherited from class org.antlr.runtime.BaseRecognizer
DEFAULT_TOKEN_CHANNEL, HIDDEN, INITIAL_FOLLOW_STACK_SIZE, MEMO_RULE_FAILED, MEMO_RULE_UNKNOWN, NEXT_TOKEN_RULE_NAME, state
 
Constructor Summary
CallFileLexer()
           
CallFileLexer(org.antlr.runtime.CharStream input)
           
CallFileLexer(org.antlr.runtime.CharStream input, org.antlr.runtime.RecognizerSharedState state)
           
CallFileLexer(String s)
          Call file lexer.
CallFileLexer(String s, boolean useIndentProcessor)
           
 
Method Summary
 String getGrammarFileName()
           
 void mAFTER()
           
 void mASSERT()
           
 void mBEFORE()
           
 void mCALL()
           
 void mCOLON()
           
 void mCOMMA()
           
 void mCOMMENT()
           
 void mCONDITION()
           
 void mDEDENT()
           
 void mDEF()
           
 void mENDS()
           
 void mEQUALS()
           
 void mEXAMPLE()
           
 void mFIGURE()
           
 void mFROM()
           
 void mIDENT()
           
 void mIN()
           
 void mINDENT()
           
 void mINITIAL_WS()
           
 void mINTEGER()
           
 void mIPART()
           
 void mLANGLE()
           
 void mLBRACK()
           
 void mLEFT()
           
 void mLPAREN()
           
 void mMINUS()
           
 void mNL()
           
 void mNONE()
           
 void mOPTIONAL()
           
 void mOUT()
           
 void mPART()
           
 void mPLUS()
           
 void mPRIM()
           
 void mPROGRAM()
           
 void mQUESTION()
           
 void mRANGLE()
           
 void mRBRACK()
           
 void mRIGHT()
           
 void mRPAREN()
           
 void mSELECT()
           
 void mSLASH()
           
 void mSPOKEN()
           
 void mSTAR()
           
 void mTokens()
           
 void mVBAR()
           
 void mWS()
           
 void mWSNL()
           
 void mXPART()
           
 org.antlr.runtime.Token nextToken()
          Override superclass' nextToken to insert the IndentProcessor
 void setToRuleStart()
          Set the lexer state to begin parsing a grammar rule.
protected  org.antlr.runtime.Token superNextToken()
           
 String tokensToString()
          For testing.
 
Methods inherited from class org.antlr.runtime.Lexer
emit, emit, getCharErrorDisplay, getCharIndex, getCharPositionInLine, getCharStream, getErrorMessage, getLine, getSourceName, getText, match, match, matchAny, matchRange, recover, reportError, reset, setCharStream, setText, skip, traceIn, traceOut
 
Methods inherited from class org.antlr.runtime.BaseRecognizer
alreadyParsedRule, beginResync, combineFollows, computeContextSensitiveRuleFOLLOW, computeErrorRecoverySet, consumeUntil, consumeUntil, displayRecognitionError, emitErrorMessage, endResync, failed, getBacktrackingLevel, getCurrentInputSymbol, getErrorHeader, getMissingSymbol, getNumberOfSyntaxErrors, getRuleInvocationStack, getRuleInvocationStack, getRuleMemoization, getRuleMemoizationCacheSize, getTokenErrorDisplay, getTokenNames, match, matchAny, memoize, mismatchIsMissingToken, mismatchIsUnwantedToken, pushFollow, recover, recoverFromMismatchedSet, recoverFromMismatchedToken, setBacktrackingLevel, toStrings, traceIn, traceOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBS

public static final int ATTRIBS
See Also:
Constant Field Values

APPLY

public static final int APPLY
See Also:
Constant Field Values

STAR

public static final int STAR
See Also:
Constant Field Values

LBRACK

public static final int LBRACK
See Also:
Constant Field Values

DEF

public static final int DEF
See Also:
Constant Field Values

SPOKEN

public static final int SPOKEN
See Also:
Constant Field Values

LANGLE

public static final int LANGLE
See Also:
Constant Field Values

PART

public static final int PART
See Also:
Constant Field Values

IPART

public static final int IPART
See Also:
Constant Field Values

CONDITION

public static final int CONDITION
See Also:
Constant Field Values

EQUALS

public static final int EQUALS
See Also:
Constant Field Values

DEDENT

public static final int DEDENT
See Also:
Constant Field Values

EOF

public static final int EOF
See Also:
Constant Field Values

LPAREN

public static final int LPAREN
See Also:
Constant Field Values

INDENT

public static final int INDENT
See Also:
Constant Field Values

IF

public static final int IF
See Also:
Constant Field Values

VBAR

public static final int VBAR
See Also:
Constant Field Values

INITIAL_WS

public static final int INITIAL_WS
See Also:
Constant Field Values

RPAREN

public static final int RPAREN
See Also:
Constant Field Values

SLASH

public static final int SLASH
See Also:
Constant Field Values

EXPR

public static final int EXPR
See Also:
Constant Field Values

IN

public static final int IN
See Also:
Constant Field Values

ARG

public static final int ARG
See Also:
Constant Field Values

SEQ

public static final int SEQ
See Also:
Constant Field Values

COMMA

public static final int COMMA
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

PAR

public static final int PAR
See Also:
Constant Field Values

IDENT

public static final int IDENT
See Also:
Constant Field Values

PLUS

public static final int PLUS
See Also:
Constant Field Values

BODY

public static final int BODY
See Also:
Constant Field Values

NL

public static final int NL
See Also:
Constant Field Values

RANGLE

public static final int RANGLE
See Also:
Constant Field Values

COMMENT

public static final int COMMENT
See Also:
Constant Field Values

ADJ

public static final int ADJ
See Also:
Constant Field Values

SELECT

public static final int SELECT
See Also:
Constant Field Values

INTEGER

public static final int INTEGER
See Also:
Constant Field Values

RBRACK

public static final int RBRACK
See Also:
Constant Field Values

PRIM

public static final int PRIM
See Also:
Constant Field Values

ITEM

public static final int ITEM
See Also:
Constant Field Values

FIGURE

public static final int FIGURE
See Also:
Constant Field Values

OPT

public static final int OPT
See Also:
Constant Field Values

NUMBER

public static final int NUMBER
See Also:
Constant Field Values

XPART

public static final int XPART
See Also:
Constant Field Values

BEFORE

public static final int BEFORE
See Also:
Constant Field Values

CALLLIST

public static final int CALLLIST
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

AFTER

public static final int AFTER
See Also:
Constant Field Values

MINUS

public static final int MINUS
See Also:
Constant Field Values

ASSERT

public static final int ASSERT
See Also:
Constant Field Values

EXAMPLE

public static final int EXAMPLE
See Also:
Constant Field Values

OPTIONAL

public static final int OPTIONAL
See Also:
Constant Field Values

REF

public static final int REF
See Also:
Constant Field Values

COLON

public static final int COLON
See Also:
Constant Field Values

WS

public static final int WS
See Also:
Constant Field Values

QUESTION

public static final int QUESTION
See Also:
Constant Field Values

OUT

public static final int OUT
See Also:
Constant Field Values

ENDS

public static final int ENDS
See Also:
Constant Field Values

NONE

public static final int NONE
See Also:
Constant Field Values

PROGRAM

public static final int PROGRAM
See Also:
Constant Field Values

CALL

public static final int CALL
See Also:
Constant Field Values

FROM

public static final int FROM
See Also:
Constant Field Values

WSNL

public static final int WSNL
See Also:
Constant Field Values

indentProcessor

public final CallFileLexer.IndentProcessor indentProcessor

dfa14

protected net.cscott.sdr.calls.parser.CallFileLexer.DFA14 dfa14
Constructor Detail

CallFileLexer

public CallFileLexer(String s)
Call file lexer. Call files are indent-sensitive, like Python. An inner IndentProcessor is used to convert leading whitespace into synthetic INDENT/DEDENT tokens, where appropriate.

Tests:
Simple tokens:
js> new CallFileLexer("program: basic").tokensToString()
1.0: "program"
1.7: ":"
1.9: "basic"
0.-1: <EOF>
INITIAL_WS should trigger at the beginning of every line:
js> new CallFileLexer("+", false).tokensToString() // length-1 match
1.0: <INITIAL_WS>""
1.0: "+"
0.-1: <EOF>
js> new CallFileLexer("// foo", false).tokensToString() // comments
1.0: <INITIAL_WS>""
0.-1: <EOF>
js> new CallFileLexer("program: basic", false).tokensToString() //IDENT
1.0: <INITIAL_WS>""
1.0: "program"
1.7: ":"
1.9: "basic"
0.-1: <EOF>
Indent processing with spaces:
js> new CallFileLexer("program: basic\n def: foo").tokensToString()
1.0: "program"
1.7: ":"
1.9: "basic"
2.1: "<indent>"
2.1: "def"
2.4: ":"
2.6: "foo"
0.-1: "<dedent>"
0.-1: <EOF>
Tab stops at 8-character boundaries:
js> new CallFileLexer("foo\n \tbar\n        bat").tokensToString()
1.0: "foo"
2.2: "<indent>"
2.2: "bar"
3.8: "bat"
0.-1: "<dedent>"
0.-1: <EOF>
Multiple indentation levels:
js> new CallFileLexer("foo\n bar\n\tbat\nbaz").tokensToString()
1.0: "foo"
2.1: "<indent>"
2.1: "bar"
3.1: "<indent>"
3.1: "bat"
4.0: "<dedent>"
4.0: "<dedent>"
4.0: "baz"
0.-1: <EOF>
js> new CallFileLexer("foo\n bar\n\tbat\n baz").tokensToString()
1.0: "foo"
2.1: "<indent>"
2.1: "bar"
3.1: "<indent>"
3.1: "bat"
4.1: "<dedent>"
4.1: "baz"
0.-1: "<dedent>"
0.-1: <EOF>
Keywords only apply before colons:
js> cl = new CallFileLexer("def: def")
net.cscott.sdr.calls.parser.CallFileLexer@ce5b1c
js> cl.nextToken().getType() == cl.DEF
true
js> cl.nextToken().getType() == cl.COLON
true
js> cl.nextToken().getType() == cl.IDENT
true
js> cl.nextToken().getType()
-1
Comment match is non-greedy:
js> new CallFileLexer("/* foo *"+"/ bar /* bat *"+"/").tokensToString()
1.10: "bar"
0.-1: <EOF>
Special keywords available only after 'prim':
js> cl = new CallFileLexer("out", false)
net.cscott.sdr.calls.parser.CallFileLexer@1f3aa07
js> cl.nextToken().getType() == cl.INITIAL_WS
true
js> cl.nextToken().getType() == cl.IDENT
true
js> cl.nextToken().getType()
-1
js> cl = new CallFileLexer("prim: out", false)
net.cscott.sdr.calls.parser.CallFileLexer@1fc2fb
js> cl.nextToken().getType() == cl.INITIAL_WS
true
js> cl.nextToken().getType() == cl.PRIM
true
js> cl.nextToken().getType() == cl.COLON
true
js> cl.nextToken().getType() == cl.OUT
true
js> cl.nextToken().getType()
-1

CallFileLexer

public CallFileLexer(String s,
                     boolean useIndentProcessor)

CallFileLexer

public CallFileLexer()

CallFileLexer

public CallFileLexer(org.antlr.runtime.CharStream input)

CallFileLexer

public CallFileLexer(org.antlr.runtime.CharStream input,
                     org.antlr.runtime.RecognizerSharedState state)
Method Detail

setToRuleStart

public void setToRuleStart()
Set the lexer state to begin parsing a grammar rule.


nextToken

public org.antlr.runtime.Token nextToken()
Override superclass' nextToken to insert the IndentProcessor

Specified by:
nextToken in interface org.antlr.runtime.TokenSource
Overrides:
nextToken in class org.antlr.runtime.Lexer

superNextToken

protected org.antlr.runtime.Token superNextToken()

tokensToString

public String tokensToString()
For testing.


getGrammarFileName

public String getGrammarFileName()
Overrides:
getGrammarFileName in class org.antlr.runtime.BaseRecognizer

mINITIAL_WS

public final void mINITIAL_WS()
                       throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mCOMMENT

public final void mCOMMENT()
                    throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mINTEGER

public final void mINTEGER()
                    throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mNL

public final void mNL()
               throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mWS

public final void mWS()
               throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mWSNL

public final void mWSNL()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mFIGURE

public final void mFIGURE()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mDEF

public final void mDEF()
                throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mFROM

public final void mFROM()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mIN

public final void mIN()
               throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mSELECT

public final void mSELECT()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mCONDITION

public final void mCONDITION()
                      throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mCALL

public final void mCALL()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mPART

public final void mPART()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mIPART

public final void mIPART()
                  throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mXPART

public final void mXPART()
                  throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mPRIM

public final void mPRIM()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mPROGRAM

public final void mPROGRAM()
                    throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mOPTIONAL

public final void mOPTIONAL()
                     throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mSPOKEN

public final void mSPOKEN()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mEXAMPLE

public final void mEXAMPLE()
                    throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mBEFORE

public final void mBEFORE()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mAFTER

public final void mAFTER()
                  throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mENDS

public final void mENDS()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mASSERT

public final void mASSERT()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mOUT

public final void mOUT()
                throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mLEFT

public final void mLEFT()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mRIGHT

public final void mRIGHT()
                  throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mNONE

public final void mNONE()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mIDENT

public final void mIDENT()
                  throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mCOMMA

public final void mCOMMA()
                  throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mCOLON

public final void mCOLON()
                  throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mLPAREN

public final void mLPAREN()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mRPAREN

public final void mRPAREN()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mLBRACK

public final void mLBRACK()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mRBRACK

public final void mRBRACK()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mSLASH

public final void mSLASH()
                  throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mQUESTION

public final void mQUESTION()
                     throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mLANGLE

public final void mLANGLE()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mRANGLE

public final void mRANGLE()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mEQUALS

public final void mEQUALS()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mVBAR

public final void mVBAR()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mPLUS

public final void mPLUS()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mMINUS

public final void mMINUS()
                  throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mSTAR

public final void mSTAR()
                 throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mINDENT

public final void mINDENT()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mDEDENT

public final void mDEDENT()
                   throws org.antlr.runtime.RecognitionException
Throws:
org.antlr.runtime.RecognitionException

mTokens

public void mTokens()
             throws org.antlr.runtime.RecognitionException
Specified by:
mTokens in class org.antlr.runtime.Lexer
Throws:
org.antlr.runtime.RecognitionException

sdr 0.7

Copyright © 2006-2009 C. Scott Ananian