本文整理匯總了Java中org.antlr.v4.runtime.Token.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java Token.getText方法的具體用法?Java Token.getText怎麽用?Java Token.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.antlr.v4.runtime.Token
的用法示例。
在下文中一共展示了Token.getText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolveType
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private EObject resolveType(final ParserRuleContext ruleContext, final EObject superType) {
final EObject resolvedType;
if (superType.eIsProxy()) {
resolvedType = null;
} else {
resolvedType = create(superType.eClass(), ruleContext);
EcoreUtil.replace(unresolved, resolvedType);
final Token nameToken = ruleContext.getStart();
final String name = nameToken.getText();
final Scope typeScope = scope.with(resolvedType, TYPE_CONTAINER__TYPES);
typeScope.with(IDENTIFIABLE_ELEMENT__NAME)
.setValue(name, nameToken);
typeScope.with(unresolved.eClass().getEStructuralFeature("type"))
.setValue(superType, nameToken);
}
return resolvedType;
}
示例2: getArithmeticBinaryOperator
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private static ArithmeticBinaryExpression.Type getArithmeticBinaryOperator(Token operator)
{
switch (operator.getType()) {
case SqlBaseLexer.PLUS:
return ArithmeticBinaryExpression.Type.ADD;
case SqlBaseLexer.MINUS:
return ArithmeticBinaryExpression.Type.SUBTRACT;
case SqlBaseLexer.ASTERISK:
return ArithmeticBinaryExpression.Type.MULTIPLY;
case SqlBaseLexer.SLASH:
return ArithmeticBinaryExpression.Type.DIVIDE;
case SqlBaseLexer.PERCENT:
return ArithmeticBinaryExpression.Type.MODULUS;
}
throw new UnsupportedOperationException("Unsupported operator: " + operator.getText());
}
示例3: getComparisonOperator
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private static ComparisonExpressionType getComparisonOperator(Token symbol)
{
switch (symbol.getType()) {
case SqlBaseLexer.EQ:
return ComparisonExpressionType.EQUAL;
case SqlBaseLexer.NEQ:
return ComparisonExpressionType.NOT_EQUAL;
case SqlBaseLexer.LT:
return ComparisonExpressionType.LESS_THAN;
case SqlBaseLexer.LTE:
return ComparisonExpressionType.LESS_THAN_OR_EQUAL;
case SqlBaseLexer.GT:
return ComparisonExpressionType.GREATER_THAN;
case SqlBaseLexer.GTE:
return ComparisonExpressionType.GREATER_THAN_OR_EQUAL;
}
throw new IllegalArgumentException("Unsupported operator: " + symbol.getText());
}
示例4: getDateTimeFunctionType
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private static CurrentTime.Type getDateTimeFunctionType(Token token)
{
switch (token.getType()) {
case SqlBaseLexer.CURRENT_DATE:
return CurrentTime.Type.DATE;
case SqlBaseLexer.CURRENT_TIME:
return CurrentTime.Type.TIME;
case SqlBaseLexer.CURRENT_TIMESTAMP:
return CurrentTime.Type.TIMESTAMP;
case SqlBaseLexer.LOCALTIME:
return CurrentTime.Type.LOCALTIME;
case SqlBaseLexer.LOCALTIMESTAMP:
return CurrentTime.Type.LOCALTIMESTAMP;
}
throw new IllegalArgumentException("Unsupported special function: " + token.getText());
}
示例5: getIntervalFieldType
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private static IntervalLiteral.IntervalField getIntervalFieldType(Token token)
{
switch (token.getType()) {
case SqlBaseLexer.YEAR:
return IntervalLiteral.IntervalField.YEAR;
case SqlBaseLexer.MONTH:
return IntervalLiteral.IntervalField.MONTH;
case SqlBaseLexer.DAY:
return IntervalLiteral.IntervalField.DAY;
case SqlBaseLexer.HOUR:
return IntervalLiteral.IntervalField.HOUR;
case SqlBaseLexer.MINUTE:
return IntervalLiteral.IntervalField.MINUTE;
case SqlBaseLexer.SECOND:
return IntervalLiteral.IntervalField.SECOND;
}
throw new IllegalArgumentException("Unsupported interval field: " + token.getText());
}
示例6: unescapeStringLiteral
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
public static String unescapeStringLiteral(TerminalNode terminalNode) {
Token token = terminalNode.getSymbol();
if (token.getType() != BQLLexer.STRING_LITERAL) {
throw new IllegalArgumentException();
}
String text = token.getText();
char initialChar = text.charAt(0);
if (text.charAt(text.length() - 1) != initialChar) {
throw new IllegalArgumentException("malformed string literal");
}
text = text.substring(1, text.length() - 1);
if (initialChar == '\'') {
text = text.replace("''", "'");
} else if (initialChar == '"') {
text = text.replace("\"\"", "\"");
} else {
throw new UnsupportedOperationException("Not supported yet.");
}
return text;
}
示例7: getIntervalFieldType
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private static IntervalLiteral.IntervalField getIntervalFieldType(Token token) {
switch (token.getType()) {
case SqlBaseLexer.YEAR:
return IntervalLiteral.IntervalField.YEAR;
case SqlBaseLexer.MONTH:
return IntervalLiteral.IntervalField.MONTH;
case SqlBaseLexer.DAY:
return IntervalLiteral.IntervalField.DAY;
case SqlBaseLexer.HOUR:
return IntervalLiteral.IntervalField.HOUR;
case SqlBaseLexer.MINUTE:
return IntervalLiteral.IntervalField.MINUTE;
case SqlBaseLexer.SECOND:
return IntervalLiteral.IntervalField.SECOND;
default:
throw new IllegalArgumentException("Unsupported interval field: " + token.getText());
}
}
示例8: getComparisonOperator
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private static ComparisonExpression.Type getComparisonOperator(Token symbol) {
switch (symbol.getType()) {
case SqlBaseLexer.EQ:
return ComparisonExpression.Type.EQUAL;
case SqlBaseLexer.NEQ:
return ComparisonExpression.Type.NOT_EQUAL;
case SqlBaseLexer.LT:
return ComparisonExpression.Type.LESS_THAN;
case SqlBaseLexer.LTE:
return ComparisonExpression.Type.LESS_THAN_OR_EQUAL;
case SqlBaseLexer.GT:
return ComparisonExpression.Type.GREATER_THAN;
case SqlBaseLexer.GTE:
return ComparisonExpression.Type.GREATER_THAN_OR_EQUAL;
default:
throw new IllegalArgumentException("Unsupported operator: " + symbol.getText());
}
}
示例9: exitFunctionDecl
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
@Override
public void exitFunctionDecl(HogwashParser.FunctionDeclContext ctx) {
boolean optionalArgsStarted = false;
for (Symbol sym : this.currentScope.getAllSymbols()) {
ArgumentSymbol arg = (ArgumentSymbol) sym;
if (arg.hasDefault()) optionalArgsStarted = true;
else if (optionalArgsStarted) {
Token tk = arg.getToken();
String name = tk.getText();
ErrorMessage em = new ErrorMessage(ErrorKind.OPT_ARG_NOT_LAST, name);
this.generateError(arg.getToken(), em);
break;
}
}
this.currentScope = this.currentScope.getEnclosingScope();
}
示例10: exitDeclaration
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
@Override
public void exitDeclaration(ObjCParser.DeclarationContext ctx) {
String decl = getCode(ctx.declaration_minus_semi()) + ";\n";
//獲取注釋
Token prior = ctx.getStart();
int indx = prior.getTokenIndex();
List<Token> cmtChannel = tokens.getHiddenTokensToLeft(indx,
ObjCLexer.COMMENT_CHANNEL);
if (cmtChannel != null) {
String txt = "";
for (Token cmt : cmtChannel) {
if (cmt != null) {
txt = txt + cmt.getText() + "\n";
}
}
setComment(ctx, txt);
}
if (getComment(ctx) != null) {
decl = getComment(ctx) + decl;
}
setCode(ctx, decl);
}
示例11: enterVerbExpr
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
@Override
public void enterVerbExpr(
de.interactive_instruments.antlr.sbvr.SBVRParser.VerbExprContext ctx) {
Token verbToken = ctx.verb;
if (verbToken != null) {
String concept = verbToken.getText();
/*
* TODO this simple noun check is usually done automatically using the
* SbvrParserHelper; a more thorough test could be performed here
*/
if (!isVerb(concept)) {
String msg = concept + " is not a known verb concept.";
addErrorMessage(Category.NOT_A_VERB_CONCEPT, msg, verbToken);
}
}
}
示例12: getArithmeticBinaryOperator
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private static ArithmeticBinaryExpression.Type getArithmeticBinaryOperator(Token operator) {
switch (operator.getType()) {
case SqlBaseLexer.PLUS:
return ArithmeticBinaryExpression.Type.ADD;
case SqlBaseLexer.MINUS:
return ArithmeticBinaryExpression.Type.SUBTRACT;
case SqlBaseLexer.ASTERISK:
return ArithmeticBinaryExpression.Type.MULTIPLY;
case SqlBaseLexer.SLASH:
return ArithmeticBinaryExpression.Type.DIVIDE;
case SqlBaseLexer.PERCENT:
return ArithmeticBinaryExpression.Type.MODULUS;
default:
throw new UnsupportedOperationException("Unsupported operator: " + operator.getText());
}
}
示例13: visitNameExpr
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
@Override
public Expression visitNameExpr(NameExprContext ctx) {
List<String> names = new ArrayList<String>();
for (Token t : ctx.values) {
String s = t.getText();
// strip leading and trailing "'"
names.add(s.substring(1, s.length() - 1));
}
if (names.size() == 1) {
StringLiteral sl = new StringLiteral();
sl.setValue(names.get(0));
return sl;
} else {
StringLiteralList sll = new StringLiteralList();
sll.setValues(names);
return sll;
}
}
示例14: resolve
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
public Symbol resolve(Token token) throws UndefinedIdentifierException {
String id = token.getText();
if (!table.containsKey(id)) {
throw new UndefinedIdentifierException(new Symbol(token));
}
return table.get(id);
}
示例15: Symbol
import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
public Symbol(Token token) {
this.id = token.getText();
line = token.getLine();
// TODO: do we need + 1? since in a lot of editors column and line all starts from 1
// in ANTLR line starts from 1, but char index start from 0
column = token.getCharPositionInLine();
type = DataType.UNDEFINED_TYPE;
}