本文整理了Java中antlr.Token.getColumn()
方法的一些代码示例,展示了Token.getColumn()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Token.getColumn()
方法的具体详情如下:
包路径:antlr.Token
类名称:Token
方法名:getColumn
暂无
代码示例来源:origin: checkstyle/checkstyle
@Override
public void initialize(Token tok) {
super.initialize(tok);
lineNo = tok.getLine();
// expect columns to start @ 0
columnNo = tok.getColumn() - 1;
}
代码示例来源:origin: jenkinsci/jenkins
private void error(String msg) throws TokenStreamException, SemanticException {
Token token = LT(0);
throw new SemanticException(
msg,
token.getFilename(),
token.getLine(),
token.getColumn()
);
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public void initialize(Token tok) {
super.initialize(tok);
filename = tok.getFilename();
line = tok.getLine();
column = tok.getColumn();
String text = tok.getText();
textLength = StringHelper.isEmpty(text) ? 0 : text.length();
}
代码示例来源:origin: checkstyle/checkstyle
/**
* Create block comment from token.
* @param token
* Token object.
* @return DetailAST with BLOCK_COMMENT type.
*/
public static DetailAST createBlockCommentNode(Token token) {
final DetailAST blockComment = new DetailAST();
blockComment.initialize(TokenTypes.BLOCK_COMMENT_BEGIN, BLOCK_MULTIPLE_COMMENT_BEGIN);
// column counting begins from 0
blockComment.setColumnNo(token.getColumn() - 1);
blockComment.setLineNo(token.getLine());
final DetailAST blockCommentContent = new DetailAST();
blockCommentContent.setType(TokenTypes.COMMENT_CONTENT);
// column counting begins from 0
// plus length of '/*'
blockCommentContent.setColumnNo(token.getColumn() - 1 + 2);
blockCommentContent.setLineNo(token.getLine());
blockCommentContent.setText(token.getText());
final DetailAST blockCommentClose = new DetailAST();
blockCommentClose.initialize(TokenTypes.BLOCK_COMMENT_END, BLOCK_MULTIPLE_COMMENT_END);
final Map.Entry<Integer, Integer> linesColumns = countLinesColumns(
token.getText(), token.getLine(), token.getColumn());
blockCommentClose.setLineNo(linesColumns.getKey());
blockCommentClose.setColumnNo(linesColumns.getValue());
blockComment.addChild(blockCommentContent);
blockComment.addChild(blockCommentClose);
return blockComment;
}
代码示例来源:origin: checkstyle/checkstyle
/**
* Create single-line comment from token.
* @param token to create the AST
* @return DetailAST with SINGLE_LINE_COMMENT type
*/
private static DetailAST createSlCommentNode(Token token) {
final DetailAST slComment = new DetailAST();
slComment.setType(TokenTypes.SINGLE_LINE_COMMENT);
slComment.setText("//");
// column counting begins from 0
slComment.setColumnNo(token.getColumn() - 1);
slComment.setLineNo(token.getLine());
final DetailAST slCommentContent = new DetailAST();
slCommentContent.setType(TokenTypes.COMMENT_CONTENT);
// column counting begins from 0
// plus length of '//'
slCommentContent.setColumnNo(token.getColumn() - 1 + 2);
slCommentContent.setLineNo(token.getLine());
slCommentContent.setText(token.getText());
slComment.addChild(slCommentContent);
return slComment;
}
代码示例来源:origin: com.puppycrawl.tools/checkstyle
@Override
public void initialize(Token tok) {
super.initialize(tok);
lineNo = tok.getLine();
// expect columns to start @ 0
columnNo = tok.getColumn() - 1;
}
代码示例来源:origin: org.glassfish.external/antlr
public MismatchedTokenException(String[] tokenNames_, Token token_, BitSet set_, boolean matchNot, String fileName_) {
super("Mismatched Token", fileName_, token_.getLine(), token_.getColumn());
tokenNames = tokenNames_;
token = token_;
tokenText = token_.getText();
mismatchType = matchNot ? NOT_SET : SET;
set = set_;
}
代码示例来源:origin: org.glassfish.external/antlr
public MismatchedTokenException(String[] tokenNames_, Token token_, int lower, int upper_, boolean matchNot, String fileName_) {
super("Mismatched Token", fileName_, token_.getLine(), token_.getColumn());
tokenNames = tokenNames_;
token = token_;
tokenText = token_.getText();
mismatchType = matchNot ? NOT_RANGE : RANGE;
expecting = lower;
upper = upper_;
}
代码示例来源:origin: org.glassfish.external/antlr
public ActionElement(Grammar g, Token t) {
super(g);
actionText = t.getText();
line = t.getLine();
column = t.getColumn();
}
代码示例来源:origin: jplag/jplag
public void add(int type, antlr.Token tok) {
if (tok == null) {
System.out.println("tok == null ERROR!");
return;
}
struct.addToken(new CSharpToken(type, currentFile, tok.getLine(), tok.getColumn(), tok.getText().length()));
// System.out.println("type: " + CSharpToken.type2string(type) +
// " text: '"+tok.getText()+"'");
}
代码示例来源:origin: org.jboss.seam/jboss-seam
public SemanticException createSemanticException(String message, Token element) {
return new SemanticException(
message,
element.getFilename(), element.getLine(), element.getColumn()
);
}
代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all
public void initialize(Token tok) {
super.initialize(tok);
filename = tok.getFilename();
line = tok.getLine();
column = tok.getColumn();
String text = tok.getText();
textLength = StringHelper.isEmpty(text) ? 0 : text.length();
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
@Override
public void initialize(Token tok) {
super.initialize(tok);
filename = tok.getFilename();
line = tok.getLine();
column = tok.getColumn();
String text = tok.getText();
textLength = StringHelper.isEmpty(text) ? 0 : text.length();
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
private void error(String msg) throws TokenStreamException, SemanticException {
Token token = LT(0);
throw new SemanticException(
msg,
token.getFilename(),
token.getLine(),
token.getColumn()
);
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
private void error(String msg) throws TokenStreamException, SemanticException {
Token token = LT(0);
throw new SemanticException(
msg,
token.getFilename(),
token.getLine(),
token.getColumn()
);
}
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
private void error(String msg) throws TokenStreamException, SemanticException {
Token token = LT(0);
throw new SemanticException(
msg,
token.getFilename(),
token.getLine(),
token.getColumn()
);
}
}
代码示例来源:origin: org.glassfish.external/antlr
public void setOption(Token option, Token value) {
if (option.getText().equals("AST")) {
setASTNodeType(value.getText());
}
else {
grammar.antlrTool.error("Invalid element option:" + option.getText(),
grammar.getFilename(), option.getLine(), option.getColumn());
}
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
/**
* Clones the token
*/
public Token cloneToken(Token t) {
CommonToken clone = new CommonToken(t.getType(),t.getText());
clone.setLine(t.getLine());
clone.setColumn(t.getColumn());
return clone;
}
代码示例来源:origin: org.glassfish.main.persistence.cmp/cmp-support-ejb
/** */
public void initialize(Token t)
{
setType(t.getType());
setText(t.getText());
setLine(t.getLine());
setColumn(t.getColumn());
}
代码示例来源:origin: org.glassfish.external/antlr
public void beginTree(Token tok) throws SemanticException {
if (!(grammar instanceof TreeWalkerGrammar)) {
tool.error("Trees only allowed in TreeParser", grammar.getFilename(), tok.getLine(), tok.getColumn());
throw new SemanticException("Trees only allowed in TreeParser");
}
super.beginTree(tok);
blocks.push(new TreeBlockContext());
context().block = new TreeElement(grammar, tok);
context().altNum = 0; // reset alternative number
}
内容来源于网络,如有侵权,请联系作者删除!