Search in sources :

Example 11 with Asn1Parser

use of org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser 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;
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) Reference(org.eclipse.titan.designer.AST.Reference) Asn1Lexer(org.eclipse.titan.designer.parsers.asn1parser.Asn1Lexer) StringReader(java.io.StringReader) ASN1Listener(org.eclipse.titan.designer.parsers.asn1parser.ASN1Listener) UnbufferedCharStream(org.antlr.v4.runtime.UnbufferedCharStream) ModuleLevelTokenStreamTracker(org.eclipse.titan.designer.parsers.asn1parser.ModuleLevelTokenStreamTracker) TokenWithIndexAndSubTokensFactory(org.eclipse.titan.designer.parsers.asn1parser.TokenWithIndexAndSubTokensFactory) CharStream(org.antlr.v4.runtime.CharStream) UnbufferedCharStream(org.antlr.v4.runtime.UnbufferedCharStream)

Example 12 with Asn1Parser

use of org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Integer_Type method parseBlockInt.

private void parseBlockInt() {
    if (null == mBlock) {
        return;
    }
    final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mBlock);
    if (null == parser) {
        return;
    }
    namedNumbers = parser.pr_special_NamedNumberList().namedValues;
    final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
    if (null != errors && !errors.isEmpty()) {
        isErroneous = true;
        namedNumbers = null;
        for (int i = 0; i < errors.size(); i++) {
            ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
        }
    }
    if (namedNumbers != null) {
        namedNumbers.setFullNameParent(this);
        namedNumbers.setMyScope(getMyScope());
    }
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage)

Example 13 with Asn1Parser

use of org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Sequence_Type method parseBlockSequence.

/**
 * Parses the block as if it were the block of a sequence.
 */
public void parseBlockSequence() {
    if (null == mBlock) {
        return;
    }
    final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mBlock);
    if (null == parser) {
        return;
    }
    components = parser.pr_special_ComponentTypeLists().list;
    final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
    if (null != errors && !errors.isEmpty()) {
        // isErroneous = true;
        components = null;
        for (int i = 0; i < errors.size(); i++) {
            ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
        }
    }
    if (components == null) {
        isErroneous = true;
        return;
    }
    components.setFullNameParent(this);
    components.setMyScope(getMyScope());
    components.setMyType(this);
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage)

Example 14 with Asn1Parser

use of org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser in project titan.EclipsePlug-ins by eclipse.

the class Undefined_Block_Value method parseBlockRelativeObjectIdentifierValue.

private RelativeObjectIdentifier_Value parseBlockRelativeObjectIdentifierValue() {
    if (null == mBlock) {
        return null;
    }
    final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mBlock);
    if (null == parser) {
        return null;
    }
    final RelativeObjectIdentifier_Value value = parser.pr_special_RelativeObjectIdentifierValue().value;
    final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
    if (null != errors && !errors.isEmpty()) {
        isErroneous = true;
        for (int i = 0; i < errors.size(); i++) {
            ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
        }
        return null;
    }
    return value;
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage)

Example 15 with Asn1Parser

use of org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser in project titan.EclipsePlug-ins by eclipse.

the class Undefined_Block_Value method parseBlockSetofValue.

private SetOf_Value parseBlockSetofValue() {
    if (null == mBlock) {
        return null;
    }
    final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mBlock);
    if (null == parser) {
        return null;
    }
    final SetOf_Value value = parser.pr_special_SetOfValue().value;
    final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
    if (null != errors && !errors.isEmpty()) {
        isErroneous = true;
        for (int i = 0; i < errors.size(); i++) {
            ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
        }
        return null;
    }
    return value;
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage) SetOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)

Aggregations

Asn1Parser (org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser)25 SyntacticErrorStorage (org.eclipse.titan.common.parsers.SyntacticErrorStorage)24 StringReader (java.io.StringReader)2 CharStream (org.antlr.v4.runtime.CharStream)2 UnbufferedCharStream (org.antlr.v4.runtime.UnbufferedCharStream)2 ASN1Listener (org.eclipse.titan.designer.parsers.asn1parser.ASN1Listener)2 Asn1Lexer (org.eclipse.titan.designer.parsers.asn1parser.Asn1Lexer)2 ModuleLevelTokenStreamTracker (org.eclipse.titan.designer.parsers.asn1parser.ModuleLevelTokenStreamTracker)2 TokenWithIndexAndSubTokensFactory (org.eclipse.titan.designer.parsers.asn1parser.TokenWithIndexAndSubTokensFactory)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Token (org.antlr.v4.runtime.Token)1 ASN1Assignment (org.eclipse.titan.designer.AST.ASN1.ASN1Assignment)1 ASN1Object (org.eclipse.titan.designer.AST.ASN1.ASN1Object)1 ASN1Type (org.eclipse.titan.designer.AST.ASN1.ASN1Type)1 ObjectSet_definition (org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition)1 ObjectSet (org.eclipse.titan.designer.AST.ASN1.ObjectSet)1 AtNotations (org.eclipse.titan.designer.AST.AtNotations)1 Constraint (org.eclipse.titan.designer.AST.Constraint)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1