net.cscott.sdr.calls.parser
Class CallFileLexer
java.lang.Object
org.antlr.runtime.BaseRecognizer
org.antlr.runtime.Lexer
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
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 |
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 |
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
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)
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
Copyright © 2006-2009 C. Scott Ananian