use of org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.Pr_UnifiedReferenceParserContext in project titan.EclipsePlug-ins by eclipse.
the class TTCN3ReferenceAnalyzer method parse.
/**
* @return the parsed reference or null if the text can not form a reference
*/
public Reference parse(final IFile file, final String code, final boolean reportErrors, final int aLine, final int aOffset) {
Reference reference = null;
Reader reader = new StringReader(code);
CharStream charStream = new UnbufferedCharStream(reader);
Ttcn3Lexer lexer = new Ttcn3Lexer(charStream);
lexer.setTokenFactory(new CommonTokenFactory(true));
lexer.initRootInterval(code.length());
lexer.removeErrorListeners();
final CommonTokenStream tokenStream = new CommonTokenStream(lexer);
Ttcn3Parser parser = new Ttcn3Parser(tokenStream);
ParserUtilities.setBuildParseTree(parser);
lexer.setActualFile(file);
parser.setActualFile(file);
parser.setProject(file.getProject());
parser.setLine(aLine);
parser.setOffset(aOffset);
parser.removeErrorListeners();
final Pr_UnifiedReferenceParserContext root = parser.pr_UnifiedReferenceParser();
ParserUtilities.logParseTree(root, parser);
reference = root.reference;
return reference;
}
use of org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.Pr_UnifiedReferenceParserContext in project titan.EclipsePlug-ins by eclipse.
the class TTCN3ReferenceAnalyzer method parseForCompletion.
/**
* Parses the provided elements. If the contents of an editor are to be parsed,
* than the file parameter is only used to report the errors to.
*
* @param file the file to parse, and report the errors to
* @param code the contents of an editor, or null.
*/
public Reference parseForCompletion(final IFile file, final String code) {
Reference reference = null;
Reader reader = new StringReader(code);
CharStream charStream = new UnbufferedCharStream(reader);
Ttcn3KeywordlessLexer lexer = new Ttcn3KeywordlessLexer(charStream);
lexer.setTokenFactory(new CommonTokenFactory(true));
lexer.initRootInterval(code.length());
lexer.removeErrorListeners();
final CommonTokenStream tokenStream = new CommonTokenStream(lexer);
Ttcn3Parser parser = new Ttcn3Parser(tokenStream);
ParserUtilities.setBuildParseTree(parser);
lexer.setActualFile(file);
parser.setActualFile(file);
parser.setProject(file.getProject());
parser.removeErrorListeners();
final Pr_UnifiedReferenceParserContext root = parser.pr_UnifiedReferenceParser();
ParserUtilities.logParseTree(root, parser);
reference = root.reference;
return reference;
}
Aggregations