Search in sources :

Example 11 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage 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 12 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage 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 13 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage 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 14 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage 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)

Example 15 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage 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;
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) Asn1Lexer(org.eclipse.titan.designer.parsers.asn1parser.Asn1Lexer) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage) 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) ASN1Assignment(org.eclipse.titan.designer.AST.ASN1.ASN1Assignment) TokenWithIndexAndSubTokensFactory(org.eclipse.titan.designer.parsers.asn1parser.TokenWithIndexAndSubTokensFactory) CharStream(org.antlr.v4.runtime.CharStream) UnbufferedCharStream(org.antlr.v4.runtime.UnbufferedCharStream)

Aggregations

SyntacticErrorStorage (org.eclipse.titan.common.parsers.SyntacticErrorStorage)26 Asn1Parser (org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser)24 StringReader (java.io.StringReader)2 CharStream (org.antlr.v4.runtime.CharStream)2 UnbufferedCharStream (org.antlr.v4.runtime.UnbufferedCharStream)2 IFile (org.eclipse.core.resources.IFile)2 TITANMarker (org.eclipse.titan.common.parsers.TITANMarker)2 Location (org.eclipse.titan.designer.AST.Location)2 Reader (java.io.Reader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CommonTokenFactory (org.antlr.v4.runtime.CommonTokenFactory)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1 Token (org.antlr.v4.runtime.Token)1 IPath (org.eclipse.core.runtime.IPath)1 IDocument (org.eclipse.jface.text.IDocument)1 Position (org.eclipse.jface.text.Position)1 TitanListener (org.eclipse.titan.common.parsers.TitanListener)1 CfgAnalyzer (org.eclipse.titan.common.parsers.cfg.CfgAnalyzer)1 CfgLocation (org.eclipse.titan.common.parsers.cfg.CfgLocation)1