Package de.odysseus.el.tree.impl
Class Scanner
- java.lang.Object
-
- de.odysseus.el.tree.impl.Scanner
-
public class Scanner extends java.lang.Object
Handcrafted scanner.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Scanner.ExtensionToken
static class
Scanner.ScanException
Scan exception typestatic class
Scanner.Symbol
Symbol typestatic class
Scanner.Token
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringBuilder
builder
private static java.util.HashMap<Scanner.Symbol,Scanner.Token>
FIXMAP
private java.lang.String
input
private static java.util.HashMap<java.lang.String,Scanner.Token>
KEYMAP
private int
position
private Scanner.Token
token
-
Constructor Summary
Constructors Modifier Constructor Description protected
Scanner(java.lang.String input)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
addFixToken(Scanner.Token token)
private static void
addKeyToken(Scanner.Token token)
protected Scanner.Token
fixed(Scanner.Symbol symbol)
java.lang.String
getInput()
int
getPosition()
Scanner.Token
getToken()
protected boolean
isDigit(char c)
protected boolean
isEval()
protected Scanner.Token
keyword(java.lang.String s)
Scanner.Token
next()
Scan next token.protected Scanner.Token
nextEval()
token inside an eval expressionprotected Scanner.Token
nextNumber()
number tokenprotected Scanner.Token
nextString()
string tokenprotected Scanner.Token
nextText()
text tokenprotected Scanner.Token
nextToken()
protected Scanner.Token
token(Scanner.Symbol symbol, java.lang.String value, int length)
-
-
-
Field Detail
-
KEYMAP
private static final java.util.HashMap<java.lang.String,Scanner.Token> KEYMAP
-
FIXMAP
private static final java.util.HashMap<Scanner.Symbol,Scanner.Token> FIXMAP
-
token
private Scanner.Token token
-
position
private int position
-
input
private final java.lang.String input
-
builder
protected final java.lang.StringBuilder builder
-
-
Method Detail
-
addFixToken
private static void addFixToken(Scanner.Token token)
-
addKeyToken
private static void addKeyToken(Scanner.Token token)
-
getInput
public java.lang.String getInput()
-
getToken
public Scanner.Token getToken()
- Returns:
- current token
-
getPosition
public int getPosition()
- Returns:
- current input position
-
isDigit
protected boolean isDigit(char c)
- Returns:
true
iff the specified character is a digit
-
keyword
protected Scanner.Token keyword(java.lang.String s)
- Parameters:
s
- name- Returns:
- token for the given keyword or
null
-
fixed
protected Scanner.Token fixed(Scanner.Symbol symbol)
- Parameters:
symbol
-- Returns:
- token for the given symbol
-
token
protected Scanner.Token token(Scanner.Symbol symbol, java.lang.String value, int length)
-
isEval
protected boolean isEval()
-
nextText
protected Scanner.Token nextText() throws Scanner.ScanException
text token- Throws:
Scanner.ScanException
-
nextString
protected Scanner.Token nextString() throws Scanner.ScanException
string token- Throws:
Scanner.ScanException
-
nextNumber
protected Scanner.Token nextNumber() throws Scanner.ScanException
number token- Throws:
Scanner.ScanException
-
nextEval
protected Scanner.Token nextEval() throws Scanner.ScanException
token inside an eval expression- Throws:
Scanner.ScanException
-
nextToken
protected Scanner.Token nextToken() throws Scanner.ScanException
- Throws:
Scanner.ScanException
-
next
public Scanner.Token next() throws Scanner.ScanException
Scan next token. After calling this method,getToken()
andgetPosition()
can be used to retreive the token's image and input position.- Returns:
- scanned token
- Throws:
Scanner.ScanException
-
-