Search in sources :

Example 16 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Enumerated_Type method parseBlockEnumeration.

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

Example 17 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage in project titan.EclipsePlug-ins by eclipse.

the class TableConstraint method parseBlocks.

private void parseBlocks() {
    if (mObjectSetBlock == null) {
        return;
    }
    objectSet = null;
    atNotationList = null;
    if (null != mObjectSetBlock) {
        if (mAtNotationsBlock == null) {
            // SimpleTableConstraint
            Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mObjectSetBlock, 0);
            if (parser != null) {
                objectSet = parser.pr_special_ObjectSetSpec().definition;
                List<SyntacticErrorStorage> errors = parser.getErrorStorage();
                if (null != errors && !errors.isEmpty()) {
                    objectSet = null;
                    for (int i = 0; i < errors.size(); i++) {
                        ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mObjectSetBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
                    }
                }
            }
        } else {
            // ComponentRelationConstraint
            Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mObjectSetBlock, 0);
            if (parser != null) {
                objectSet = parser.pr_DefinedObjectSetBlock().objectSet;
                List<SyntacticErrorStorage> errors = parser.getErrorStorage();
                if (null != errors && !errors.isEmpty()) {
                    objectSet = null;
                    for (int i = 0; i < errors.size(); i++) {
                        ParserMarkerSupport.createOnTheFlySyntacticMarker((IFile) mObjectSetBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
                    }
                }
            }
            parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mAtNotationsBlock, 0);
            if (parser != null) {
                atNotationList = parser.pr_AtNotationList().notationList;
                List<SyntacticErrorStorage> errors = parser.getErrorStorage();
                if (null != errors && !errors.isEmpty()) {
                    objectSet = null;
                    for (int i = 0; i < errors.size(); i++) {
                        ParserMarkerSupport.createOnTheFlySyntacticMarker((IFile) mAtNotationsBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
                    }
                }
            }
            if (atNotationList == null) {
                atNotationList = new AtNotations();
            }
        }
    }
    if (objectSet == null) {
        objectSet = new ObjectSet_definition();
    }
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) ObjectSet_definition(org.eclipse.titan.designer.AST.ASN1.Object.ObjectSet_definition) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage) Constraint(org.eclipse.titan.designer.AST.Constraint) AtNotations(org.eclipse.titan.designer.AST.AtNotations)

Example 18 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage in project titan.EclipsePlug-ins by eclipse.

the class Parameterised_Reference method addAssignments.

/**
 * Fill the assignments according to the formal parameters
 * @param aAssPard (in) formal parameters for the conversion
 * @param aCompilationTimeStamp compilation timestamp
 */
private void addAssignments(final Ass_pard aAssPard, final CompilationTimeStamp aCompilationTimeStamp) {
    final List<FormalParameter_Helper> formalParameters = aAssPard.getFormalParameters(aCompilationTimeStamp);
    final int nofFormalParameters = formalParameters.size();
    if (null != mBlock) {
        final List<List<Token>> actualParameters = new ArrayList<List<Token>>();
        List<Token> temporalBuffer = new ArrayList<Token>();
        // TODO: implement according to the C++ code:
        // See AST_asn1.cc/void Ass_pard::preparse_pars()
        // The java version handles only the list of references.
        // The tokens containing assignments are not handled properly
        /* splitting the list of actual parameters */
        final List<Token> unprocessParameters = mBlock.getTokenList();
        for (int i = 0; i < unprocessParameters.size(); i++) {
            final Token tempToken = unprocessParameters.get(i);
            if (tempToken.getType() == Asn1Lexer.COMMA) {
                temporalBuffer.add(new TokenWithIndexAndSubTokens(Token.EOF));
                actualParameters.add(temporalBuffer);
                temporalBuffer = new ArrayList<Token>();
            } else {
                temporalBuffer.add(tempToken);
            }
        }
        if (!temporalBuffer.isEmpty()) {
            temporalBuffer.add(new TokenWithIndexAndSubTokens(Token.EOF));
            actualParameters.add(temporalBuffer);
        }
        /* checking the number of parameters */
        final int nofActualParameters = actualParameters.size();
        if (nofActualParameters != nofFormalParameters) {
            location.reportSemanticError(MessageFormat.format(DIFFERENTPARAMETERNUMBERS, (nofActualParameters < nofFormalParameters) ? "few" : "many", nofFormalParameters, nofActualParameters));
        }
        assignments = new ASN1Assignments();
        for (int i = 0; i < nofFormalParameters; i++) {
            final Identifier tempIdentifier = formalParameters.get(i).identifier;
            ASN1Assignment temporalAssignment = null;
            if (i < nofActualParameters) {
                final List<Token> temporalTokenBuffer = new ArrayList<Token>();
                temporalTokenBuffer.add(formalParameters.get(i).formalParameterToken);
                final Token temporalToken = formalParameters.get(i).governorToken;
                if (null != temporalToken) {
                    temporalTokenBuffer.add(temporalToken);
                }
                temporalTokenBuffer.add(new TokenWithIndexAndSubTokens(Asn1Lexer.ASSIGNMENT));
                temporalTokenBuffer.addAll(actualParameters.get(i));
                // parse temp_tokenBuffer as an assignment
                // List<ANTLRException> exceptions = null;
                final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(new Block(temporalTokenBuffer, location));
                if (null != parser) {
                    temporalAssignment = parser.pr_special_Assignment().assignment;
                    final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
                    if (null != errors && !errors.isEmpty()) {
                        isErroneous = true;
                        temporalAssignment = null;
                        for (int j = 0; j < errors.size(); j++) {
                            ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mBlock.getLocation().getFile(), errors.get(j), IMarker.SEVERITY_ERROR);
                        }
                    }
                }
            }
            if (null == temporalAssignment) {
                temporalAssignment = new Type_Assignment(tempIdentifier, null, null);
            }
            temporalAssignment.setLocation(location);
            assignments.addAssignment(temporalAssignment);
        }
        for (List<Token> temporalActualParamater : actualParameters) {
            temporalActualParamater.clear();
        }
        actualParameters.clear();
    }
}
Also used : TokenWithIndexAndSubTokens(org.eclipse.titan.designer.parsers.asn1parser.TokenWithIndexAndSubTokens) ArrayList(java.util.ArrayList) Token(org.antlr.v4.runtime.Token) Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) Identifier(org.eclipse.titan.designer.AST.Identifier) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage) ArrayList(java.util.ArrayList) List(java.util.List) FormalParameter_Helper(org.eclipse.titan.designer.parsers.asn1parser.FormalParameter_Helper)

Example 19 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage in project titan.EclipsePlug-ins by eclipse.

the class ObjectSet_definition method parseBlockObjectSetSpecifications.

private void parseBlockObjectSetSpecifications() {
    if (mBlock == null) {
        return;
    }
    final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mBlock);
    if (parser == null) {
        return;
    }
    final ObjectSet_definition temporalDefinition = parser.pr_special_ObjectSetSpec().definition;
    // internalIndex += parser.nof_consumed_tokens();
    final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
    if (null != errors && !errors.isEmpty()) {
        for (int i = 0; i < errors.size(); i++) {
            ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
        }
    }
    if (null == temporalDefinition) {
        isErroneous = true;
        return;
    }
    temporalDefinition.getObjectSetElements();
    for (int i = 0; i < temporalDefinition.getObjectSetElements().size(); i++) {
        addObjectSetElement(temporalDefinition.getObjectSetElements().get(i));
    }
    temporalDefinition.setObjectSetElements(null);
    setMyScope(getMyScope());
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage)

Example 20 with SyntacticErrorStorage

use of org.eclipse.titan.common.parsers.SyntacticErrorStorage in project titan.EclipsePlug-ins by eclipse.

the class Ass_pard method check.

/**
 * Pre-process the block of formal parameters into a list. This list
 * together with actual parameters can be used to identify the
 * assignments correctly.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 */
public void check(final CompilationTimeStamp timestamp) {
    if (null != lastTimeChecked && (!isErroneous || !lastTimeChecked.isLess(timestamp))) {
        return;
    }
    lastTimeChecked = timestamp;
    isErroneous = false;
    if (null == mParameterList) {
        isErroneous = true;
        return;
    }
    if (null != mParameters) {
        return;
    }
    final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mParameterList);
    mParameters = parser.pr_special_FormalParameterList().parameters;
    final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
    if (null != errors && !errors.isEmpty()) {
        mParameters = null;
        for (int i = 0; i < errors.size(); i++) {
            ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mParameterList.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
        }
    }
    if (null == mParameters) {
        isErroneous = true;
    } else {
        mParameters.trimToSize();
    }
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage)

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