当前位置: 首页>>代码示例>>Java>>正文


Java Token.getStopIndex方法代码示例

本文整理汇总了Java中org.antlr.v4.runtime.Token.getStopIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Token.getStopIndex方法的具体用法?Java Token.getStopIndex怎么用?Java Token.getStopIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.antlr.v4.runtime.Token的用法示例。


在下文中一共展示了Token.getStopIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: containsOffset

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
/**
 * @requires token != null
 * @return true iff token contains offset or offset is at the start of token
 *         and forwardBias is true.
 */
private static boolean containsOffset(
        Token token,
        int offset,
        boolean forwardBias) {

    int startIndex;
    int stopIndex;

    if (forwardBias) {
        startIndex = token.getStartIndex();
        stopIndex = token.getStopIndex();
    } else {
        startIndex = token.getStartIndex() + 1;
        stopIndex = token.getStopIndex() + 1;
    }

    return startIndex <= offset && offset <= stopIndex;
}
 
开发者ID:mwillema,项目名称:protobuf-netbeans-plugin,代码行数:24,代码来源:AntlrDocument.java

示例2: underlineError

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
protected static String underlineError(CoqFTParser parser,
		Token offendingToken, int line, int charPositionInLine) {
	StringBuilder sb = new StringBuilder();
	
	CommonTokenStream tokens = (CommonTokenStream)parser.getInputStream();
	String input = tokens.getTokenSource().getInputStream().toString();
	String[] lines = input.split("\n");
	String errorLine = lines[line - 1];
	
	sb.append(errorLine).append('\n');
	
	for (int i=0; i<charPositionInLine; i++) sb.append(" ");
	int start = offendingToken.getStartIndex();
	int stop = offendingToken.getStopIndex();
	if ( start>=0 && stop>=0 ) {
		for (int i=start; i<=stop; i++) sb.append("^");
	}
	return sb.toString();
}
 
开发者ID:jhuapl-saralab,项目名称:exterminator,代码行数:20,代码来源:CoqSyntaxException.java

示例3: Problem

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
/**
 * create a problem which spans the entire context (grammar rule) passed to it
 * @param message a description of the problem
 * @param ctx the context (grammar rule) which the problem pertains to.
 */
Problem(String message, ParserRuleContext ctx, Severity severity) {
    this.message = message;
    this.severity = severity;

    if(ctx != null) {
        lineNum = ctx.getStart().getLine();
        rangeStart = ctx.getStart().getStartIndex();

        // appears to be null only if the input is an empty string
        Token stop = ctx.getStop();
        if(stop != null) {
            rangeEnd = stop.getStopIndex();
        } else {
            rangeEnd = rangeStart;
        }
    } else {
        lineNum = NO_LINE_NUM;
        rangeStart = -1;
        rangeEnd = -1;
    }
}
 
开发者ID:mbway,项目名称:Simulizer,代码行数:27,代码来源:Problem.java

示例4: getBytes

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private static byte[] getBytes(Literal_value_binaryContext rule) {
    Token token = rule.STRING_LITERAL().getSymbol();
    byte[] bytes = new byte[token.getStopIndex() - token.getStartIndex() - 1];
    CharStream cs = token.getInputStream();
    int pos = cs.index();
    cs.seek(token.getStartIndex() + 1);
    int j = 0;
    for (int i = 0; i < bytes.length; i++) {
        int ch = cs.LA(i + 1);
        if (ch == '\\') {
            i++;
            ch = cs.LA(i + 1);
            if (ch == '0') {
                ch = 0;
            }
            else if (ch == 'n') {
                ch = '\n';
            }
            else if (ch == 'r') {
                ch = '\r';
            }
            else if (ch == 'Z') {
                ch = '\032';
            }
        }
        bytes[j] = (byte) ch;
        j++;
    }
    cs.seek(pos);
    if (j != bytes.length) {
        // esacpe characters
        byte[] old = bytes;
        bytes = new byte[j];
        System.arraycopy(old, 0, bytes, 0, j);
    }
    return bytes;
}
 
开发者ID:waterguo,项目名称:antsdb,代码行数:38,代码来源:ExprGenerator.java

示例5: AntlrError

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
public AntlrError(Token tokenError, int line, int charPositionInLine, String msg) {
    this.line = line;
    this.charPositionInLine = charPositionInLine;
    this.msg = msg;
    this.start = tokenError == null ? -1 : tokenError.getStartIndex();
    this.stop = tokenError == null ? -1 : tokenError.getStopIndex();
    this.text = tokenError == null ? null : tokenError.getText();
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:9,代码来源:AntlrError.java

示例6: Location

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
public Location(ParserRuleContext parserRuleContext) {
  Token start = parserRuleContext.getStart();
  this.start = start.getStartIndex();
  Token stop = parserRuleContext.getStop();
  end = stop.getStopIndex();
  line = start.getLine();
}
 
开发者ID:rockscript,项目名称:rockscript,代码行数:8,代码来源:Location.java

示例7: isUnclosedBlockComment

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
@Override
protected boolean isUnclosedBlockComment(Token token) {
    if (!isBlockComment(token)) {
        return false;
    }

    if (containsBlockCommentOpeningSymbol(token)) {
        return true;
    }

    return token.getStopIndex() >= text().length() - 1;
}
 
开发者ID:mwillema,项目名称:protobuf-netbeans-plugin,代码行数:13,代码来源:ProtobufDocument.java

示例8: containsBlockCommentOpeningSymbol

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
/**
 * @requires token != null && token.type = BLOCK_COMMENT
 * @return true iff token contains another block comment opening symbol '/*'
 */
private boolean containsBlockCommentOpeningSymbol(Token token) {
    int startOffset = token.getStartIndex() + 2;
    int stopOffset = token.getStopIndex() - 1;

    if (startOffset > stopOffset) {
        return false;
    }

    return text()
            .substring(startOffset, stopOffset)
            .contains(BLOCK_COMMENT_OPENING_SYMBOL);
}
 
开发者ID:mwillema,项目名称:protobuf-netbeans-plugin,代码行数:17,代码来源:ProtobufDocument.java

示例9: getOffsetRange

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
public static OffsetRange getOffsetRange(Token start, Token stop) {
    OffsetRange offset = new OffsetRange();
    offset.startOffset = start.getStartIndex();
    offset.stopOffset = stop.getStopIndex();
    offset.startLine = start.getLine();
    offset.startLineColumn = start.getCharPositionInLine();
    offset.stopLine = stop.getLine();
    offset.stopLineColumn = stop.getCharPositionInLine();
    return offset;
}
 
开发者ID:kasonyang,项目名称:kalang,代码行数:11,代码来源:OffsetRangeHelper.java

示例10: setTotalBoundaries

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private void setTotalBoundaries(Token token) {
	if (state.in(NameRecognitionState.NAME1, NameRecognitionState.QUALIFIER, NameRecognitionState.NAME2)) {
		if (totalLo < 0)
			totalLo = token.getStartIndex();
		if (totalHi < token.getStopIndex())
			totalHi = token.getStopIndex();
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:9,代码来源:NameRecognition.java

示例11: underlineError

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
protected <T extends Token> void underlineError(
		Recognizer<T, ?> recognizer, Token offendingToken, int line,
		int charPositionInLine) {
	
	CommonTokenStream tokens = (CommonTokenStream) recognizer
			.getInputStream();
	
	String input = tokens.getTokenSource().getInputStream().toString();
	
	String[] lines = input.split("\n");
	
	String errorLine = lines[line - 1];
	
	System.out.println(errorLine);
	
	for (int i = 0; i < charPositionInLine; i++)
		System.out.print(" ");
	
	int start = offendingToken.getStartIndex();
	int stop = offendingToken.getStopIndex();
	
	if (start >= 0 && stop >= 0) {
		for (int i = start; i <= stop; i++)
			System.out.print("^");
	}
	System.out.println();
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:28,代码来源:SbvrErrorListener.java

示例12: setMetadataFromContext

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
public void setMetadataFromContext(ParserRuleContext ctx) {

		Token start = ctx.start;
		Token stop = ctx.stop;

		this.offendingTextStartIndex = start.getStartIndex();
		this.offendingTextStopIndex = stop.getStopIndex();
	}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:9,代码来源:SbvrErrorInfo.java

示例13: syntaxError

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
		String msg, RecognitionException e) {
	super.syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);

	this.line = line;

	if (recognizer.getInputStream() instanceof CommonTokenStream) {
		StringBuilder errorBuilder = new StringBuilder(msg);

		CommonTokenStream tokenStream = (CommonTokenStream) recognizer.getInputStream();
		errorBuilder.append("\n");

		String expression = tokenStream.getTokenSource().getInputStream().toString();
		String[] split = expression.split("(\r\n|\n)");
		String error = null;
		if (split.length > 0) {
			if (line - 1 >= 0 && line - 1 < split.length) {
				error = split[line - 1].replace("\t", " ");
			} else {
				error = split[split.length - 1].replace("\t", " ");
			}
			errorBuilder.append(error);
			errorBuilder.append("\n");
		} else {
			errorBuilder.append(expression);
			errorBuilder.append("\n");
		}

		for (int i = 0; i < charPositionInLine; i++) {
			errorBuilder.append(" ");
		}

		if (offendingSymbol instanceof Token) {
			Token token = (Token) offendingSymbol;
			int startIndex = token.getStartIndex();
			int stopIndex = token.getStopIndex();
			if (startIndex >= 0 && stopIndex >= 0 && startIndex <= stopIndex) {
				for (int i = token.getStartIndex(); i <= token.getStopIndex(); i++) {
					errorBuilder.append("^");
				}
			} else {
				errorBuilder.append("^");
			}
		} else {
			errorBuilder.append("^");
		}

		errorMessage = errorBuilder.toString();
	} else {
		errorMessage = msg;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:54,代码来源:ExpressionErrorListener.java

示例14: create

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
public static SyntaxElement create(Token t, SyntaxElementType type) {
	return new SyntaxElement(t.getText(), t.getStartIndex(), t.getStopIndex(), t.getTokenIndex(), type);
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:4,代码来源:SyntaxElement.java

示例15: setMetadataFromToken

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
public void setMetadataFromToken(Token token) {

		this.offendingTextStartIndex = token.getStartIndex();
		this.offendingTextStopIndex = token.getStopIndex();
	}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:6,代码来源:SbvrErrorInfo.java


注:本文中的org.antlr.v4.runtime.Token.getStopIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。