use of org.eclipse.titan.designer.parsers.asn1parser.Asn1Lexer in project titan.EclipsePlug-ins by eclipse.
the class ASN1ReferenceParser method parseReference.
private Reference parseReference(final IFile file, final String input, final int line, final int offset) {
Reference reference = null;
StringReader reader = new StringReader(input);
CharStream charStream = new UnbufferedCharStream(reader);
Asn1Lexer lexer = new Asn1Lexer(charStream);
lexer.setTokenFactory(new TokenWithIndexAndSubTokensFactory(true));
ASN1Listener lexerListener = new ASN1Listener();
// remove ConsoleErrorListener
lexer.removeErrorListeners();
lexer.addErrorListener(lexerListener);
ModuleLevelTokenStreamTracker tracker = new ModuleLevelTokenStreamTracker(lexer);
tracker.discard(Asn1Lexer.WS);
tracker.discard(Asn1Lexer.MULTILINECOMMENT);
tracker.discard(Asn1Lexer.SINGLELINECOMMENT);
Asn1Parser parser = new Asn1Parser(tracker);
parser.setProject(file.getProject());
parser.setActualFile(file);
parser.setLine(line);
parser.setOffset(offset);
parser.setBuildParseTree(false);
ASN1Listener parserListener = new ASN1Listener();
// remove ConsoleErrorListener
parser.removeErrorListeners();
parser.addErrorListener(parserListener);
reference = parser.pr_parseReference().reference;
return reference;
}
use of org.eclipse.titan.designer.parsers.asn1parser.Asn1Lexer in project titan.EclipsePlug-ins by eclipse.
the class SpecialASN1Module method parseSpecialInternalAssignment.
/**
* Parses the special internal assignments to build their semantic
* representation.
*
* @param inputCode
* the code to parse.
* @param identifier
* the identifier for the assignment to be created.
*
* @return the parsed assignment.
*/
public static ASN1Assignment parseSpecialInternalAssignment(final String inputCode, final Identifier identifier) {
ASN1Assignment assignment = null;
final StringReader reader = new StringReader(inputCode);
final CharStream charStream = new UnbufferedCharStream(reader);
final Asn1Lexer lexer = new Asn1Lexer(charStream);
lexer.setTokenFactory(new TokenWithIndexAndSubTokensFactory(true));
final ASN1Listener lexerListener = new ASN1Listener();
// remove ConsoleErrorListener
lexer.removeErrorListeners();
lexer.addErrorListener(lexerListener);
final ModuleLevelTokenStreamTracker tracker = new ModuleLevelTokenStreamTracker(lexer);
tracker.discard(Asn1Lexer.WS);
tracker.discard(Asn1Lexer.MULTILINECOMMENT);
tracker.discard(Asn1Lexer.SINGLELINECOMMENT);
final Asn1Parser parser = new Asn1Parser(tracker);
parser.setBuildParseTree(false);
final ASN1Listener parserListener = new ASN1Listener(parser);
// remove ConsoleErrorListener
parser.removeErrorListeners();
parser.addErrorListener(parserListener);
assignment = parser.pr_TITAN_special_Assignment(identifier).assignment;
if (!parser.getErrorStorage().isEmpty()) {
ErrorReporter.INTERNAL_ERROR(PARSINGFAILED);
for (SyntacticErrorStorage temp : parser.getErrorStorage()) {
ErrorReporter.logError(temp.message);
}
}
return assignment;
}
Aggregations