Java Code Examples for org.antlr.runtime.Token#getInputStream()

The following examples show how to use org.antlr.runtime.Token#getInputStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicSemanticChecks.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void checkInvalidRuleDef(Token ruleID) {
	String fileName = null;
	if ( ruleID.getInputStream()!=null ) {
		fileName = ruleID.getInputStream().getSourceName();
	}
	if ( g.isLexer() && Character.isLowerCase(ruleID.getText().charAt(0)) ) {
		g.tool.errMgr.grammarError(ErrorType.PARSER_RULES_NOT_ALLOWED,
								   fileName, ruleID, ruleID.getText());
	}
	if ( g.isParser() &&
		Grammar.isTokenName(ruleID.getText()) )
	{
		g.tool.errMgr.grammarError(ErrorType.LEXER_RULES_NOT_ALLOWED,
								   fileName, ruleID, ruleID.getText());
	}
}
 
Example 2
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 3
Source File: ANTLRv4ExternalAnnotator.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean tokenBelongsToFile(Token t, @NotNull PsiFile file) {
	CharStream inputStream = t.getInputStream();
	if ( inputStream instanceof ANTLRFileStream ) {
		// Not equal if the token belongs to an imported grammar
		return inputStream.getSourceName().equals(file.getVirtualFile().getCanonicalPath());
	}

	return true;
}
 
Example 4
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
CharStream input = t.getInputStream();
String srcName = null;
if ( input!=null ) {
	srcName = input.getSourceName();
	if ( srcName!=null ) srcName = Misc.getFileName(srcName);
}
listener.compileTimeError(
          new STCompiletimeMessage(error,srcName,templateToken,t,null,t.getText())
      );
  }
 
Example 5
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 6
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 7
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 8
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 9
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 10
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 11
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 12
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 13
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 14
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 15
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 16
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 17
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 18
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}
 
Example 19
Source File: ErrorManager.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void compileTimeError(ErrorType error, Token templateToken, Token t) {
    CharStream input = t.getInputStream();
    String srcName = null;
    if ( input!=null ) {
        srcName = input.getSourceName();
        if ( srcName!=null ) srcName = Misc.getFileName(srcName);
    }
    listener.compileTimeError(new STCompiletimeMessage(error, srcName, templateToken, t, null, t.getText()));
}