类 Label
- java.lang.Object
-
- org.antlr.analysis.Label
-
- 所有已实现的接口:
java.lang.Cloneable
,java.lang.Comparable<Label>
- 直接已知子类:
ActionLabel
,PredicateLabel
public class Label extends java.lang.Object implements java.lang.Comparable<Label>, java.lang.Cloneable
A state machine transition label. A label can be either a simple label such as a token or character. A label can be a set of char or tokens. It can be an epsilon transition. It can be a semantic predicate (which assumes an epsilon transition) or a tree of predicates (in a DFA). Special label types have to be < 0 to avoid conflict with char.
-
-
字段概要
字段 修饰符和类型 字段 说明 static int
ACTION
static int
DOWN
static int
EOF
static int
EOR_TOKEN_TYPE
End of rule token type; imaginary token type used only for local, partial FOLLOW sets to indicate that the local FOLLOW hit the end of rule.static int
EOT
End of Token is like EOF for lexer rules.static int
EPSILON
static java.lang.String
EPSILON_STR
static int
INVALID
protected int
label
The token type or character value; or, signifies special label.protected IntSet
labelSet
A set of token types or character codes if label==SETstatic int
MAX_CHAR_VALUE
static int
MIN_ATOM_VALUE
Anything at this value or larger can be considered a simple atom int for easy comparison during analysis only; faux labels are not used during parse time for real token types or char values.static int
MIN_CHAR_VALUE
static int
MIN_TOKEN_TYPE
tokens and char range overlap; tokens are MIN_TOKEN_TYPE..nstatic int
NUM_FAUX_LABELS
We have labels like EPSILON that are below 0; it's hard to store them in an array with negative index so use this constant as an index shift when accessing arrays based upon token type.static int
SEMPRED
label is a semantic predicate; implies label is epsilon alsostatic int
SET
label is a set of tokens or charstatic int
UP
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 void
add(Label a)
java.lang.Object
clone()
int
compareTo(Label o)
boolean
equals(java.lang.Object o)
int
getAtom()
return the single atom label or INVALID if not a single atomSemanticContext
getSemanticContext()
IntSet
getSet()
int
hashCode()
static boolean
intersect(Label label, Label edgeLabel)
boolean
isAction()
boolean
isAtom()
boolean
isEpsilon()
boolean
isSemanticPredicate()
boolean
isSet()
boolean
matches(int atom)
boolean
matches(Label other)
boolean
matches(IntSet set)
void
setSet(IntSet set)
java.lang.String
toString()
Predicates are lists of AST nodes from the NFA created from the grammar, but the same predicate could be cut/paste into multiple places in the grammar.java.lang.String
toString(Grammar g)
-
-
-
字段详细资料
-
INVALID
public static final int INVALID
- 另请参阅:
- 常量字段值
-
ACTION
public static final int ACTION
- 另请参阅:
- 常量字段值
-
EPSILON
public static final int EPSILON
- 另请参阅:
- 常量字段值
-
EPSILON_STR
public static final java.lang.String EPSILON_STR
- 另请参阅:
- 常量字段值
-
SEMPRED
public static final int SEMPRED
label is a semantic predicate; implies label is epsilon also- 另请参阅:
- 常量字段值
-
SET
public static final int SET
label is a set of tokens or char- 另请参阅:
- 常量字段值
-
EOT
public static final int EOT
End of Token is like EOF for lexer rules. It implies that no more characters are available and that NFA conversion should terminate for this path. For example A : 'a' 'b' | 'a' ; yields a DFA predictor: o-a->o-b->1 predict alt 1 | |-EOT->o predict alt 2 To generate code for EOT, treat it as the "default" path, which implies there is no way to mismatch a char for the state from which the EOT emanates.- 另请参阅:
- 常量字段值
-
EOF
public static final int EOF
- 另请参阅:
- 常量字段值
-
NUM_FAUX_LABELS
public static final int NUM_FAUX_LABELS
We have labels like EPSILON that are below 0; it's hard to store them in an array with negative index so use this constant as an index shift when accessing arrays based upon token type. If real token type is i, then array index would be NUM_FAUX_LABELS + i.- 另请参阅:
- 常量字段值
-
MIN_ATOM_VALUE
public static final int MIN_ATOM_VALUE
Anything at this value or larger can be considered a simple atom int for easy comparison during analysis only; faux labels are not used during parse time for real token types or char values.- 另请参阅:
- 常量字段值
-
MIN_CHAR_VALUE
public static final int MIN_CHAR_VALUE
- 另请参阅:
- 常量字段值
-
MAX_CHAR_VALUE
public static final int MAX_CHAR_VALUE
- 另请参阅:
- 常量字段值
-
EOR_TOKEN_TYPE
public static final int EOR_TOKEN_TYPE
End of rule token type; imaginary token type used only for local, partial FOLLOW sets to indicate that the local FOLLOW hit the end of rule. During error recovery, the local FOLLOW of a token reference may go beyond the end of the rule and have to use FOLLOW(rule). I have to just shift the token types to 2..n rather than 1..n to accommodate this imaginary token in my bitsets. If I didn't use a bitset implementation for runtime sets, I wouldn't need this. EOF is another candidate for a run time token type for parsers. Follow sets are not computed for lexers so we do not have this issue.- 另请参阅:
- 常量字段值
-
DOWN
public static final int DOWN
- 另请参阅:
- 常量字段值
-
UP
public static final int UP
- 另请参阅:
- 常量字段值
-
MIN_TOKEN_TYPE
public static final int MIN_TOKEN_TYPE
tokens and char range overlap; tokens are MIN_TOKEN_TYPE..n- 另请参阅:
- 常量字段值
-
label
protected int label
The token type or character value; or, signifies special label.
-
labelSet
protected IntSet labelSet
A set of token types or character codes if label==SET
-
-
构造器详细资料
-
Label
public Label(int label)
-
Label
public Label(IntSet labelSet)
Make a set label
-
-
方法详细资料
-
clone
public java.lang.Object clone()
- 覆盖:
clone
在类中java.lang.Object
-
add
public void add(Label a)
-
isAtom
public boolean isAtom()
-
isEpsilon
public boolean isEpsilon()
-
isSemanticPredicate
public boolean isSemanticPredicate()
-
isAction
public boolean isAction()
-
isSet
public boolean isSet()
-
getAtom
public int getAtom()
return the single atom label or INVALID if not a single atom
-
getSet
public IntSet getSet()
-
setSet
public void setSet(IntSet set)
-
getSemanticContext
public SemanticContext getSemanticContext()
-
matches
public boolean matches(int atom)
-
matches
public boolean matches(IntSet set)
-
matches
public boolean matches(Label other)
-
hashCode
public int hashCode()
- 覆盖:
hashCode
在类中java.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- 覆盖:
equals
在类中java.lang.Object
-
toString
public java.lang.String toString()
Predicates are lists of AST nodes from the NFA created from the grammar, but the same predicate could be cut/paste into multiple places in the grammar. I must compare the text of all the predicates to truly answer whether {p1,p2} .equals {p1,p2}. Unfortunately, I cannot rely on the AST.equals() to work properly so I must do a brute force O(n^2) nested traversal of the Set doing a String compare. At this point, Labels are not compared for equals when they are predicates, but here's the code for future use.- 覆盖:
toString
在类中java.lang.Object
-
toString
public java.lang.String toString(Grammar g)
-
-