Fatal error in code colorizer.Colorizing has been disabled

Mar 29, 2013 at 7:17 PM
When I Press the Parse button after loading the text and grammar I get a dialog box with the following message.Can any one tell me why is it happening? The grammar is very large and I can not insert it here
System.NullReferenceException: Object reference not set to an instance of an object.
at Irony.Parsing.Parser.ExecuteNextAction() in f:\cloud\SLA\OCL\irony_e79458979314\Irony\Parsing\Parser\Parser.cs:line 119
at Irony.Parsing.Parser.ParseAll() in f:\cloud\SLA\OCL\irony_e79458979314\Irony\Parsing\Parser\Parser.cs:line 101
at Irony.Parsing.Parser.Parse(String sourceText, String fileName) in f:\cloud\SLA\OCL\irony_e79458979314\Irony\Parsing\Parser\Parser.cs:line 75
at Irony.GrammarExplorer.fmGrammarExplorer.ParseSample() in f:\cloud\SLA\OCL\irony_e79458979314\Irony.GrammarExplorer\fmGrammarExplorer.cs:line 348
at Irony.GrammarExplorer.fmGrammarExplorer.btnParse_Click(Object sender, EventArgs e) in f:\cloud\SLA\OCL\irony_e79458979314\Irony.GrammarExplorer\fmGrammarExplorer.cs:line 507
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Coordinator
Mar 29, 2013 at 8:22 PM
well, debug into it and see what's happening. Most likely smth wrong with your grammar, but.. parser shouldn't crash on bad grammars, so likely some sleeping bug in Irony
Roman
Mar 30, 2013 at 3:53 PM
Here i have put the grammar fully part by part .please follow the following posts.
``` using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Irony.Parsing;
using PGSoftwareSolutionsInc.PGIrony;
using System.Globalization;

namespace Irony.Samples.EMFOCL2
{
/// <summary>
/// Description of EMOFOCL2Grammer.
/// </summary>
[Language("SLAng", "2", "SLAng grammar")]
public class SLAngGrammer: PGSoftwareSolutionsInc.PGIrony.Grammar<MyAstContext>
{
    public SLAngGrammer(): base(false,LanguageFlags.CreateAst)
    {
        StringLiteral stringLiteral = TerminalFactory.CreateCSharpString("StringLiteral");
        StringLiteral charLiteral = TerminalFactory.CreateCSharpChar("CharLiteral");
        NumberLiteral number = TerminalFactory.CreateCSharpNumber("Number");
        IdentifierTerminal identifier = TerminalFactory.CreateCSharpIdentifier("Identifier");
        CommentTerminal delimitedComment = new CommentTerminal("DelimitedComment", "/[", "]/");
        CommentTerminal SingleLineComment = new CommentTerminal("SingleLineComment", "--","\r", "\n", "\u2085", "\u2028", "\u2029");
        NonGrammarTerminals.Add(SingleLineComment);
        NonGrammarTerminals.Add(delimitedComment);

        KeyTerm colon = ToTerm(":");      
        KeyTerm dot = ToTerm(".");
        KeyTerm comma = ToTerm(",");
        KeyTerm propertyIs = ToTerm("->");
        KeyTerm lbr = ToTerm("{");
        KeyTerm rbr = ToTerm("}");
        KeyTerm lpar = ToTerm("(");
        KeyTerm rpar = ToTerm(")");
        KeyTerm scopeIn = ToTerm("::");
        KeyTerm suchThat = ToTerm("|");
        KeyTerm _package = ToTerm("package");
        KeyTerm context = ToTerm("context");
        KeyTerm body = ToTerm("body");
        KeyTerm def = ToTerm("def");
        KeyTerm derive = ToTerm("derive");      
        KeyTerm In = ToTerm("in");
        KeyTerm inv = ToTerm("inv");
        KeyTerm let = ToTerm("let");
        KeyTerm post = ToTerm("post");
        KeyTerm pre = ToTerm("pre");
        KeyTerm Static = ToTerm("static");
        KeyTerm self = ToTerm("self");      
        KeyTerm result = ToTerm("result");
        KeyTerm equalsTo = ToTerm("=");
        KeyTerm _null = ToTerm("null");
        KeyTerm invalid = ToTerm("invalid");
        KeyTerm not =  ToTerm("not");
        KeyTerm and =  ToTerm("and");
        KeyTerm or =  ToTerm("or");
        KeyTerm xor =  ToTerm("xor");

     var specification = new TypedNonTerminal<specificationAstNode>();
     var specificationBody = new TypedNonTerminal<specificationBodyAstNode>(); 
     var package = new TypedNonTerminal<packageAstNode>();
     var packages = new TypedNonTerminal<packagesAstNode>();
     var oclPackage = new TypedNonTerminal<oclPackageAstNode>();
     var emofOclPackage = new TypedNonTerminal<emofOclPackageAstNode>();
     var packageBody = new TypedNonTerminal<packageBodyAstNode>();
     var packageBodyItem = new TypedNonTerminal<packageBodyItemAstNode>();
     var contextExp = new TypedNonTerminal<contextExpAstNode>();
     var classType = new TypedNonTerminal<classTypeAstNode>(); 
     var enumeration = new TypedNonTerminal<enumerationAstNode>();
     var primitive = new TypedNonTerminal<primitiveAstNode>();
     var primitiveType = new TypedNonTerminal<primitiveTypeDeclerationAstNode>();
     var primitiveTypes = new TypedNonTerminal<primitiveTypesAstNode>();
     var delimitedIdentifier = new TypedNonTerminal<delimitedIdentifierAstNode>();
     var classSignature = new TypedNonTerminal<classSignatureAstNode>();
     var classBody = new TypedNonTerminal<classBodyAstNode>();
     var classBodyItem = new TypedNonTerminal<classBodyItemAstNode>();
     var invExp  = new TypedNonTerminal<invExpAstNode>();
     var functionDefination = new TypedNonTerminal<functionDefinationAstNode>();
     var attributeDiclaration= new TypedNonTerminal<attributeDiclarationAstNode>();
     var emofAttributeDiclaration= new TypedNonTerminal<emofAttributeDiclarationAstNode>();
     var oclAttributeDiclaration= new TypedNonTerminal<oclAttributeDiclarationAstNode>();
     var type = new TypedNonTerminal<typeAstNode>();
     var expression = new TypedNonTerminal<expressionAstNode>();
     var customType = new TypedNonTerminal<customTypeAstNode>();
     var collectionTpye = new TypedNonTerminal<collectionTpyeAstNode>();
     var fullType = new TypedNonTerminal<fullTypeAstNode>();
     var globalType = new TypedNonTerminal<globalTypeAstNode>();
     var setType = new TypedNonTerminal<setTypeAstNode>();
     var orderedSetType = new TypedNonTerminal<orderedSetTypeAstNode>();
     var sequenceType = new TypedNonTerminal<sequenceTypeAstNode>();
     var bagType = new TypedNonTerminal<bagTypeAstNode>();
     var functionSignature = new TypedNonTerminal<functionSignatureAstNode>();
     var functionSignatureBody = new TypedNonTerminal<functionSignatureBodyAstNode>();
     var functionBody = new TypedNonTerminal<functionBodyAstNode>();
     var oclFunctionSignature = new TypedNonTerminal<oclFunctionSignatureAstNode>();
     var emofFunctionSignature = new TypedNonTerminal<emofFunctionSignatureAstNode>();
     var argumentList = new TypedNonTerminal<argumentListAstNode>(); 
     var variableDiclaration = new TypedNonTerminal<variableDiclarationAstNode>();
     var emofFunctionBody = new TypedNonTerminal<emofFunctionBodyAstNode>();
     var oclFunctionBody = new TypedNonTerminal<oclfunctionBodyAstNode>();
     var singleValueCollectionMember = new TypedNonTerminal<singleValueCollectionMemberAstNode>();
     var booleanValueCollection = new TypedNonTerminal<booleanValueCollectionAstNode>();
     var letExp  = new TypedNonTerminal<letExpAstNode>();
     var ifThenElseExp = new TypedNonTerminal<ifThenElseExpAstNode>();
     var collectionValueExp = new TypedNonTerminal<collectionValueExpAstNode>();
     var sum = new TypedNonTerminal<sumAstNode>();
     var size = new TypedNonTerminal<sizeAstNode>();
     var first  = new TypedNonTerminal<firstAstNode>(); 
     var last   = new TypedNonTerminal<lastAstNode>(); 
     var at   = new TypedNonTerminal<atAstNode>(); 
     var indexOf   = new TypedNonTerminal<indexOfAstNode>();
     var countOperation = new TypedNonTerminal<CountOperationAstNode>();
     var maxOperation = new TypedNonTerminal<maxOperationAstNode>();
     var minOperation = new TypedNonTerminal<minOperationAstNode>();
     var valueExp = new TypedNonTerminal<valueExpAstNode>();
     var includesOperation = new TypedNonTerminal<includesOperationAstNode>();
     var includesAllOperation = new TypedNonTerminal<includesAllExpAstNode>();
     var excludesOperation = new TypedNonTerminal<excludesOperationAstNode>();
     var excludesAllOperation = new TypedNonTerminal<excludesAllOperationAstNode>();
     var isEmptyOperation = new TypedNonTerminal<isEmptyOperationAstNode>();
     var notEmptyOperation = new TypedNonTerminal<notEmptyOperationAstNode>();
     var specialIteratorBodyExp = new TypedNonTerminal<specialIteratorBodyExpAstNode>();       
     var existsExp = new TypedNonTerminal<existsExpAstNode>(); 
     var forAllExp = new TypedNonTerminal<forallExpAstNode>();   
     var isUniqueExp = new TypedNonTerminal<isUniqueExpAstNode>();   
     var anyExp = new TypedNonTerminal<anyExpAstNode>();
     var oneExp = new TypedNonTerminal<oneExpAstNode>();
     var selectExp = new TypedNonTerminal<selectExpAstNode>();  
     var includingOperation = new TypedNonTerminal<includingOperationAstNode>();
     var excludingOperation = new TypedNonTerminal<excludingOperationAstNode>();
     var collect = new TypedNonTerminal<collectAstNode>();  
     var subOrderedSet   = new TypedNonTerminal<subOrderedSetAstNode>(); 
     var symmetricDifference  = new TypedNonTerminal<symmetricDifferenceAstNode>();
     var prepend   = new TypedNonTerminal<prependAstNode>();
     var append   = new TypedNonTerminal<appendAstNode>(); 
     var insertAt  = new TypedNonTerminal<insertAtAstNode>(); 
     var intersection = new TypedNonTerminal<intersectionAstNode>();
     var union = new TypedNonTerminal<unionAstNode>();
     var asBag = new TypedNonTerminal<asBagAstNode>();
     var asSequence = new TypedNonTerminal<asSequenceAstNode>();
     var asOrderdSet = new TypedNonTerminal<asOrderdSetAstNode>();
     var asSet = new TypedNonTerminal<asSetAstNode>();
     var flatten   = new TypedNonTerminal<flattenAstNode>();
     var subSequence   = new TypedNonTerminal<subSequenceAstNode>();
     var andExp= new TypedNonTerminal<andExpAstNode>();
     var orExp = new TypedNonTerminal<orExpAstNode>();
     var notExp = new TypedNonTerminal<notExpAstNode>();
     var xorExp = new TypedNonTerminal<xorExpAstNode>();
     var impliesExp = new TypedNonTerminal<impliesExpAstNode>();
     var comparisonOperator = new TypedNonTerminal<comparisonOperatorAstNode>();
     var arithmaticOperator = new  TypedNonTerminal<arithmaticOperatorAstNode>();
     var oclInvExp  = new TypedNonTerminal<oclInvExpAstNode>();
     var emofInvExp  = new TypedNonTerminal<emofInvExpAstNode>();
     var operationContextExp = new TypedNonTerminal<operationContextExpAstNode>();
     var attributeContextExp  = new TypedNonTerminal<attributeContextExpAstNode>(); 
     var classContextExp = new TypedNonTerminal<classContextExpAstNode>();
     var classContextSignature  = new TypedNonTerminal<classContextSignatureAstNode>();
Mar 30, 2013 at 4:01 PM
```
    var attributeContextbody  = new TypedNonTerminal<attributeContextbodyAstNode>();
     var attributeContextbodyItem  = new TypedNonTerminal<attributeContextbodyItemAstNode>();
     var deriveExp = new TypedNonTerminal<deriveExpAstNode>();
     var initExp = new TypedNonTerminal<initExpAstNode>();
     var operationContextBodyExps  = new TypedNonTerminal<operationContextBodyExpsAstNode>();
     var operationContextSignature  = new TypedNonTerminal<operationContextSignatureAstNode>();
     var operationContextBodyItem  = new TypedNonTerminal<operationContextBodyItemAstNode>();
     var preCondition  = new TypedNonTerminal<preConditionAstNode>();
     var postCondition  = new TypedNonTerminal<postConditionAstNode>();
     var bodyExp = new TypedNonTerminal<bodyExpAstNode>();
     var iterateExp = new TypedNonTerminal<iterateExpAstNode>();
     var productExp = new TypedNonTerminal<productExpAstNode>();
     var tupleExp = new TypedNonTerminal<tupleExpAstNode>();
     var rejectExp = new TypedNonTerminal<rejectExpAstNode>();
     var collection = new TypedNonTerminal<collectionTypeAstNode>();
     var tuplElementList = new TypedNonTerminal<tuplElementListAstNode>();
     var tupleElement = new TypedNonTerminal<tupleElementAstNode>();
     var binaryOperator = new TypedNonTerminal<binaryOperatorAstNode>();
     var parameterList= new TypedNonTerminal<parameterListAstNode>();
     var structuralExp = new TypedNonTerminal<structuralExpAstNode>();
     var setLiteral = new TypedNonTerminal<setLiteralExpAstNode>();
     var bagLiteral = new TypedNonTerminal<bagLiteralAstNode>();
     var orderedSetLiteral = new TypedNonTerminal<orderedSetLiteralAstNode>();
     var sequenceLiteral = new TypedNonTerminal<sequenceLiteralAstNode>();
     var tupleLiteral = new TypedNonTerminal<tupleLiteralAstNode>();
     var literalList = new TypedNonTerminal<literalListAstNode>();
     var iteratorList = new TypedNonTerminal<iteratorListAstNode>();
     var iteratorInitializationList = new TypedNonTerminal<iteratorInitializationListAstNode>();
     var iteratorInitialization = new TypedNonTerminal<iteratorInitializationAstNode>();
     var collectionValue = new TypedNonTerminal<collectionValueAstNode>();
     var ArrayType = new TypedNonTerminal<ArrayTypeAstNode>();
     var binaryBooleanOperator = new TypedNonTerminal<binaryBooleanOperatorAstNode>();
     var oclIsTypeOf = new TypedNonTerminal<oclIsTypeOfAstNode>();
     var typedValueExp = new TypedNonTerminal<typedValueExpAstNode>();
     var unTypedValueExp = new TypedNonTerminal<unTypedValueExpAstNode>();
     var instanceMemberAccess = new TypedNonTerminal<instanceMemberAccessAstNode>();
     var instanceMathodAccess = new TypedNonTerminal<instanceMathodAccessAstNode>();

       specification.Rule = "specification"+identifier+lbr+specificationBody+rbr;
       specificationBody.Rule = MakePlusRule(packages,package);
       package.Rule =oclPackage|emofOclPackage;
       oclPackage.Rule =_package+identifier+packageBody+"endpackage";
       emofOclPackage.Rule = _package+identifier+lbr+packageBody+rbr;
       packageBody.Rule = MakeStarRule(packageBody,null,packageBodyItem);
       packageBodyItem.Rule = primitive|enumeration|classType|contextExp|package;

       primitive.Rule="primitive"+primitiveTypes+identifier+"IDENTICAL";
       primitiveTypes.Rule = ToTerm("Real")|ToTerm("Integer")|ToTerm("String")|ToTerm("Boolean");

       enumeration.Rule ="enumeration"+identifier+lbr+delimitedIdentifier+rbr;
       delimitedIdentifier.Rule =MakePlusRule(delimitedIdentifier,comma,identifier); 

       classType.Rule = classSignature+lbr+classBody+rbr;
       classSignature.Rule  = ToTerm("class")+identifier
                              |ToTerm("abstract")+ToTerm("class")+identifier
                              |ToTerm("abstract")+ToTerm("class")+identifier+ToTerm("extends")+identifier
                              |ToTerm("class")+identifier+ToTerm("extends")+type;
       classBody.Rule = MakeStarRule(classBody,classBodyItem);
       classBodyItem.Rule =attributeDiclaration|functionDefination|invExp;

       attributeDiclaration.Rule = oclAttributeDiclaration|emofAttributeDiclaration;
       oclAttributeDiclaration.Rule = def+colon+identifier+type+ReduceHere()
                                      |def+colon+identifier+type+PreferShiftHere()+equalsTo+expression+ReduceHere()
                                      |def+colon+"attr"+identifier+type+PreferShiftHere()+equalsTo+expression+ReduceHere()
                                      |def+colon+"attr"+identifier+type+ReduceHere();
       emofAttributeDiclaration.Rule = identifier+colon+type+ReduceHere()
                                       |ToTerm("component")+identifier+colon+type+ToTerm("opposite")+identifier+ReduceHere()
                                       |ToTerm("component")+identifier+colon+type+ToTerm("unique")+ToTerm("opposite")+identifier+ReduceHere()
                                       |identifier+colon+type+equalsTo+expression+ReduceHere()
                                       |identifier+colon+type+ToTerm("opposite")+identifier+ReduceHere()
                                       |identifier+colon+type+ToTerm("unique")+ToTerm("opposite")+identifier+ReduceHere()
                                       |identifier+colon+type+ToTerm("unique")+ReduceHere();

       type.Rule = primitiveTypes|customType;
       customType.Rule = fullType|globalType|ArrayType|collectionTpye|tupleExp;
       fullType.Rule= identifier+PreferShiftHere()+scopeIn+PreferShiftHere()+fullType|identifier;
       globalType.Rule = PreferShiftHere()+scopeIn+fullType
                        |PreferShiftHere()+scopeIn+ArrayType;
       ArrayType.Rule = fullType+"["+"*"+"]"
                        |fullType+"["+identifier+"]"
                        |fullType+"["+number+"]"
                        |fullType+"["+number+comma+number+"]"
                        |fullType+"["+number+comma+"*"+"]";
       collectionTpye.Rule = setType|orderedSetType|sequenceType|bagType|collection;
       setType.Rule = "Set("+customType+")";
       orderedSetType.Rule = "OrderedSet("+customType+")";
       sequenceType.Rule = "Sequence("+customType+")";
       bagType.Rule = "Bag("+customType+")";
       collection.Rule = "Collection("+customType+")";
       tupleExp.Rule = "Tuple"+lbr+argumentList+rbr;

       functionDefination.Rule = functionSignature+functionBody;
       functionSignature.Rule = oclFunctionSignature|emofFunctionSignature;
       oclFunctionSignature.Rule = def+colon+functionSignatureBody;
       functionSignatureBody.Rule = identifier+lpar+argumentList+rpar+colon+type
                                    |identifier+lpar+argumentList+rpar+colon+type+ToTerm("ordered")+ToTerm("unique")
                                    |identifier+lpar+argumentList+rpar+colon;
       argumentList.Rule = MakePlusRule(argumentList,comma,variableDiclaration)|Empty;
       variableDiclaration.Rule = identifier+colon+type;
       emofFunctionSignature.Rule = functionSignatureBody;
       functionBody.Rule = oclFunctionBody|emofFunctionBody;
       oclFunctionBody.Rule = equalsTo+expression;
       emofFunctionBody.Rule =equalsTo+lbr+expression+rbr; 

       expression.Rule = valueExp|structuralExp;

       valueExp.Rule =typedValueExp
                     |unTypedValueExp
                     |valueExp+PreferShiftHere()+binaryOperator+valueExp
                     |ToTerm("not")+valueExp
                     |lpar+valueExp+rpar;

        unTypedValueExp.Rule = booleanValueCollection
                               |ToTerm("false")|ToTerm("true")
                               |collectionValue
                               |tupleLiteral
                               |singleValueCollectionMember
                               |collectionValueExp
                               |iterateExp
                               |stringLiteral
                               |charLiteral
                               |number
                               |self
                               |oclIsTypeOf
                               |unTypedValueExp+lpar+parameterList+rpar
                               |instanceMemberAccess
                               |instanceMathodAccess
                               |ToTerm("-")+number;

        typedValueExp.Rule = fullType+dot+instanceMemberAccess
                            |globalType+dot+instanceMemberAccess
                            |typedValueExp+dot+identifier+lpar+parameterList+rpar;

       instanceMemberAccess.Rule = MakePlusRule(instanceMemberAccess,dot,identifier);
       instanceMathodAccess.Rule = unTypedValueExp+dot+identifier+lpar+parameterList+rpar;

       parameterList.Rule = MakeStarRule(parameterList,comma,valueExp)|ifThenElseExp;

       booleanValueCollection.Rule = includesOperation|includesAllOperation|excludesOperation|excludesAllOperation
                         |isEmptyOperation|notEmptyOperation|existsExp|forAllExp|isUniqueExp|anyExp|oneExp;
Mar 30, 2013 at 4:11 PM
   oclIsTypeOf.Rule = valueExp+dot+ToTerm("oclIsTypeOf")+lpar+type+rpar;

       binaryOperator.Rule = comparisonOperator|arithmaticOperator|binaryBooleanOperator; 
       arithmaticOperator.Rule = ToTerm("/")|ToTerm("div")|ToTerm("*")|ToTerm("+")|ToTerm("-");
       comparisonOperator.Rule = ToTerm(">")|ToTerm("<")|ToTerm(">=")|ToTerm("<=")|ToTerm("<>")|equalsTo;
       binaryBooleanOperator.Rule = ToTerm("and")|ToTerm("or")|ToTerm("xor")|ToTerm("implies");


       includesOperation.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("includes")+lpar+valueExp+rpar;                  
       includesAllOperation.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("includesAll")+lpar+identifier+rpar;                         
       excludesOperation.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("excludes")+lpar+identifier+rpar;                      
       excludesAllOperation.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("excludesAll")+lpar+identifier+rpar;                           
       isEmptyOperation.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("isEmpty")+lpar+rpar;                     
       notEmptyOperation.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("notEmpty")+lpar+rpar;                     
       existsExp.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("exists")+lpar+specialIteratorBodyExp+rpar;              
       forAllExp.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("forAll")+lpar+specialIteratorBodyExp+rpar;           
       isUniqueExp.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("isUnique")+lpar+specialIteratorBodyExp+rpar;              
       anyExp.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("any")+lpar+specialIteratorBodyExp+rpar;          
       oneExp.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("one")+lpar+specialIteratorBodyExp+rpar;          
       specialIteratorBodyExp.Rule =delimitedIdentifier+colon+type+suchThat+valueExp
                                   |argumentList+suchThat+valueExp
                                   |valueExp;

       collectionValue.Rule = setLiteral|bagLiteral|orderedSetLiteral|sequenceLiteral ;
       setLiteral.Rule  = "Set"+lbr+literalList+rbr
                          |"Set"+lpar+type+rpar+lbr+literalList+rbr;
       bagLiteral.Rule  = "Bag"+lbr+literalList+rbr
                         |"Bag"+lpar+type+rpar+lbr+literalList+rbr;
       orderedSetLiteral.Rule  ="OrderedSet"+lbr+literalList+rbr
                                |"OrderedSet"+lpar+type+rpar+lbr+literalList+rbr;
       sequenceLiteral.Rule  ="Sequence"+lbr+literalList+rbr
                              |"Sequence"+lpar+type+rpar+lbr+literalList+rbr;
       literalList.Rule = MakeStarRule(literalList,comma,valueExp); 
       tupleLiteral.Rule="Tuple"+lbr+tuplElementList+rbr;
       tuplElementList.Rule = MakePlusRule(tuplElementList,comma,tupleElement);            
       tupleElement.Rule =variableDiclaration+equalsTo+valueExp|identifier+equalsTo+valueExp;
       collectionValueExp.Rule =includingOperation|excludingOperation|selectExp|rejectExp
                                |union|intersection|insertAt|append|prepend|symmetricDifference|subOrderedSet|collect|productExp
                                |subSequence|flatten|asSet|asOrderdSet|asSequence|asBag;
       includingOperation.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("including")+lpar+identifier+rpar;            
       excludingOperation.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("excluding")+lpar+identifier+rpar;
       selectExp.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("select")+lpar+specialIteratorBodyExp+rpar;
       rejectExp.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("reject")+lpar+specialIteratorBodyExp+rpar;
       union.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("union")+lpar+valueExp+rpar;
       intersection.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("intersection")+lpar+identifier+rpar;
       insertAt.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("insertAt")+lpar+number+comma+identifier+rpar;
       append.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("append")+lpar+identifier+rpar;
       prepend.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("prepend")+lpar+identifier+rpar;
       symmetricDifference.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("symmetricDifference")+lpar+identifier+rpar;                     
       subOrderedSet.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("subOrderedSet")+lpar+number+comma+number+rpar;               
       collect.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("collect")+lpar+specialIteratorBodyExp+rpar
                    |valueExp+PreferShiftHere()+propertyIs+ToTerm("collect")+lpar+identifier+rpar
                    |valueExp+dot+identifier+lpar+argumentList+rpar
                    |valueExp+PreferShiftHere()+propertyIs+identifier+lpar+argumentList+rpar;
       productExp.Rule =valueExp+PreferShiftHere()+propertyIs+ToTerm("product")+lpar+identifier+rpar;                
       subSequence.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("subSequence")+lpar+number+comma+number+rpar;                  
       flatten.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("flatten")+lpar+rpar;           
       asSet.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("asSet")+lpar+rpar;         
       asOrderdSet.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("asOrderdSet")+lpar+rpar;                 
       asSequence.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("asSequence")+lpar+rpar;              
       asBag.Rule=valueExp+PreferShiftHere()+propertyIs+ToTerm("asBag")+lpar+rpar;

       singleValueCollectionMember.Rule = maxOperation|minOperation|countOperation|at|indexOf|first|last|sum|size;
       maxOperation.Rule = valueExp+PreferShiftHere()+propertyIs+"max()"
                           |iterateExp+PreferShiftHere()+propertyIs+"max()";       
       minOperation.Rule = valueExp+PreferShiftHere()+propertyIs+"min()"
                           |iterateExp+PreferShiftHere()+propertyIs+"min()";
       countOperation.Rule = valueExp+PreferShiftHere()+propertyIs+"count("+identifier+")"
                            |iterateExp+PreferShiftHere()+propertyIs+"count("+identifier+")";
       at.Rule = valueExp+PreferShiftHere()+propertyIs+"at("+identifier+")"
                 |iterateExp+PreferShiftHere()+propertyIs+"at("+identifier+")";
       indexOf.Rule = valueExp+PreferShiftHere()+propertyIs+"indexOf("+identifier+")"
                      |iterateExp+PreferShiftHere()+propertyIs+"indexOf("+identifier+")";
       first.Rule = valueExp+PreferShiftHere()+propertyIs+"first()"
                    |iterateExp+PreferShiftHere()+propertyIs+"first()";
       last.Rule = valueExp+PreferShiftHere()+propertyIs+"last()"
                   |iterateExp+PreferShiftHere()+propertyIs+"last()";
       sum.Rule = valueExp+PreferShiftHere()+propertyIs+"sum()"
                  |iterateExp+PreferShiftHere()+propertyIs+"sum()";
       size.Rule = valueExp+PreferShiftHere()+propertyIs+"size()"
                   |iterateExp+PreferShiftHere()+propertyIs+"size()";

       iterateExp.Rule = valueExp+PreferShiftHere()+propertyIs+"iterate"+lpar+iteratorList+";"
                         +iteratorInitializationList+suchThat+expression+rpar;
       iteratorList.Rule = MakePlusRule(iteratorList,comma,variableDiclaration);
       iteratorInitializationList.Rule = MakePlusRule(iteratorInitializationList,comma,iteratorInitialization);
       iteratorInitialization.Rule = variableDiclaration+equalsTo+valueExp;

       structuralExp.Rule = ifThenElseExp|letExp;

       ifThenElseExp.Rule = "if"+valueExp+"then"+expression+"endif"
                           |"if"+valueExp+"then"+expression+"else"+expression+"endif";

       letExp.Rule = let+variableDiclaration+equalsTo+valueExp+In+expression
                    |let+identifier+equalsTo+valueExp+In+expression ;

       invExp.Rule = oclInvExp|emofInvExp;
       oclInvExp.Rule = inv+identifier+colon+expression
                        |inv+colon+expression;
       emofInvExp.Rule ="invariant"+lbr+expression+rbr;

       contextExp.Rule = classContextExp|attributeContextExp|operationContextExp;

       classContextExp.Rule = classContextSignature+classBody;
       classContextSignature.Rule = context+type
                                    |context+identifier+colon+type;
       classBody.Rule = MakePlusRule(classBody,null,classBodyItem);
       classBodyItem.Rule = invExp|attributeDiclaration|functionDefination;

       attributeContextExp.Rule = context+type+colon+type+attributeContextbody;
       attributeContextbody.Rule = MakePlusRule(attributeContextbody,null,attributeContextbodyItem);
       attributeContextbodyItem.Rule = initExp|deriveExp;

       initExp.Rule = ToTerm("init")+colon+equalsTo+valueExp;

       deriveExp.Rule = ToTerm("derive")+colon+expression;

       operationContextExp.Rule = operationContextSignature+invExp+operationContextBody
Mar 30, 2013 at 4:13 PM
operationContextSignature.Rule = context+customType+PreferShiftHere()+scopeIn+functionSignature;
       operationContextBodyExps.Rule = MakePlusRule(operationContextBodyExps,null,operationContextBodyItem);
       operationContextBodyItem.Rule = preCondition|bodyExp|postCondition;

       preCondition.Rule = pre+identifier+colon+valueExp
                          |pre+colon+valueExp;

       bodyExp.Rule = body+colon+expression;

       postCondition.Rule = post+colon+valueExp
                            |post+identifier+colon+valueExp;

       MarkPunctuation(",", "(", ")", "{", "}", "[", "]", ":");
       MarkMemberSelect(dot,propertyIs);
       RegisterOperators(1, lpar,rpar);
       RegisterOperators(2, "let","in");
       RegisterOperators(3, letExp,In);
       RegisterOperators(4, dot,scopeIn);
       RegisterOperators(5, not);
       RegisterOperators(6, "*","/");
       RegisterOperators(7, letExp,In);
       RegisterOperators(8, dot,scopeIn);
       RegisterOperators(9, "+","-");
       RegisterOperators(10, "<", ">", "<=", ">=");
       RegisterOperators(11, "=", "<>");
       RegisterOperators(12, and);
       RegisterOperators(13, or);
       RegisterOperators(14, xor);
       RegisterOperators(15, "=", "<>");

       this.Root = specification; 
    }

     public override void SkipWhitespace(ISourceStream source) {
          while (!source.EOF()) {
                 var ch = source.PreviewChar;
                 switch (ch) {
                              case ' ':
                              case '\t':
                              case '\r':
                              case '\n':
                              case '\v':
                              case '\u2085':
                              case '\u2028':
                              case '\u2029':
                                    source.PreviewPosition++;
                                    break;
                              default:
                              //Check unicode class Zs
                              UnicodeCategory chCat = char.GetUnicodeCategory(ch);
                              if (chCat == UnicodeCategory.SpaceSeparator) //it is whitespace, continue moving
                                  continue;//while loop 
                              //Otherwize return
                              return;
                }//switch
           }//while
     }

     protected override MyAstContext GetContext(LanguageData language) 
     {
        return new MyAstContext(language);
     }
}
 public class MyAstContext :PGSoftwareSolutionsInc.PGIrony.AstContext  {
    public MyAstContext(LanguageData language) : base(language) {}
}

 public class TypedNonTerminal<TAstNode> : TypedNonTerminal<MyAstContext,TAstNode> 
 where TAstNode : AstNode<MyAstContext>{}

      public class     specificationAstNode : AstNode<MyAstContext> {} 
      public class     specificationBodyAstNode : ListNode<MyAstContext> {}  
      public class     packageAstNode : AstNode<MyAstContext> {} 
      public class     packagesAstNode : AstNode<MyAstContext> {} 
      public class     oclPackageAstNode : AstNode<MyAstContext> {} 
      public class     emofOclPackageAstNode : AstNode<MyAstContext> {} 
      public class     packageBodyAstNode : ListNode<MyAstContext> {} 
      public class     packageBodyItemAstNode : AstNode<MyAstContext> {} 
      public class     contextExpAstNode : AstNode<MyAstContext> {} 
      public class     classTypeAstNode : AstNode<MyAstContext> {}  
      public class     enumerationAstNode : AstNode<MyAstContext> {} 
      public class     primitiveAstNode : AstNode<MyAstContext> {} 
      public class     primitiveTypeDeclerationAstNode : AstNode<MyAstContext> {} 
      public class     primitiveTypesAstNode : AstNode<MyAstContext> {} 
      public class     delimitedIdentifierAstNode : ListNode<MyAstContext> {} 
      public class     classSignatureAstNode : AstNode<MyAstContext> {} 
      public class     classBodyAstNode : ListNode<MyAstContext> {} 
      public class     classBodyItemAstNode : AstNode<MyAstContext> {} 
      public class     invExpAstNode : AstNode<MyAstContext> {} 
      public class     functionDefinationAstNode : AstNode<MyAstContext> {} 
      public class     attributeDiclarationAstNode : AstNode<MyAstContext> {} 
      public class     emofAttributeDiclarationAstNode : AstNode<MyAstContext> {} 
      public class     oclAttributeDiclarationAstNode : AstNode<MyAstContext> {} 
      public class     typeAstNode : AstNode<MyAstContext> {} 
      public class     expressionAstNode : AstNode<MyAstContext> {} 
      public class     customTypeAstNode : AstNode<MyAstContext> {} 
      public class     collectionTpyeAstNode : AstNode<MyAstContext> {} 
      public class     fullTypeAstNode : ListNode<MyAstContext> {} 
      public class     globalTypeAstNode : ListNode<MyAstContext> {} 
      public class     setTypeAstNode : AstNode<MyAstContext> {} 
      public class     orderedSetTypeAstNode : AstNode<MyAstContext> {} 
      public class     sequenceTypeAstNode : AstNode<MyAstContext> {} 
      public class     bagTypeAstNode : AstNode<MyAstContext> {} 
      public class     functionSignatureAstNode : AstNode<MyAstContext> {} 
      public class     functionSignatureBodyAstNode : AstNode<MyAstContext> {} 
      public class     functionBodyAstNode : AstNode<MyAstContext> {} 
      public class     oclFunctionSignatureAstNode : AstNode<MyAstContext> {} 
      public class     emofFunctionSignatureAstNode : AstNode<MyAstContext> {} 
      public class     argumentListAstNode : ListNode<MyAstContext> {}  
      public class     variableDiclarationAstNode : AstNode<MyAstContext> {} 
      public class     emofFunctionBodyAstNode : AstNode<MyAstContext> {} 
      public class     oclfunctionBodyAstNode : AstNode<MyAstContext> {} 
      public class     singleValueCollectionMemberAstNode : AstNode<MyAstContext> {} 
      public class     booleanValueCollectionAstNode : AstNode<MyAstContext> {} 
      public class     letExpAstNode : AstNode<MyAstContext> {} 
      public class     ifThenElseExpAstNode : AstNode<MyAstContext> {} 
      public class     collectionValueExpAstNode : AstNode<MyAstContext> {} 
      public class     sumAstNode : AstNode<MyAstContext> {} 
      public class     sizeAstNode : AstNode<MyAstContext> {} 
      public class     firstAstNode : AstNode<MyAstContext> {}  
      public class     lastAstNode : AstNode<MyAstContext> {}  
      public class     atAstNode : AstNode<MyAstContext> {}  
      public class     indexOfAstNode : AstNode<MyAstContext> {} 
      public class     CountOperationAstNode : AstNode<MyAstContext> {} 
      public class     maxOperationAstNode : AstNode<MyAstContext> {} 
      public class     minOperationAstNode : AstNode<MyAstContext> {} 
      public class     valueExpAstNode : AstNode<MyAstContext> {} 
      public class     includesOperationAstNode : AstNode<MyAstContext> {} 
      public class     includesAllExpAstNode : AstNode<MyAstContext> {} 
      public class     excludesOperationAstNode : AstNode<MyAstContext> {} 
      public class     excludesAllOperationAstNode : AstNode<MyAstContext> {} 
      public class     isEmptyOperationAstNode : AstNode<MyAstContext> {} 
      public class     notEmptyOperationAstNode : AstNode<MyAstContext> {} 
      public class     specialIteratorBodyExpAstNode : AstNode<MyAstContext> {}        
      public class     existsExpAstNode : AstNode<MyAstContext> {}  
      public class     forallExpAstNode : AstNode<MyAstContext> {}    
      public class     isUniqueExpAstNode : AstNode<MyAstContext> {}    
      public class     anyExpAstNode : AstNode<MyAstContext> {} 
      public class     oneExpAstNode : AstNode<MyAstContext> {} 
      public class     selectExpAstNode : AstNode<MyAstContext> {}   
      public class     includingOperationAstNode : AstNode<MyAstContext> {} 
      public class     excludingOperationAstNode : AstNode<MyAstContext> {} 
      public class     collectAstNode : AstNode<MyAstContext> {}   
      public class     subOrderedSetAstNode : AstNode<MyAstContext> {}  
      public class     symmetricDifferenceAstNode : AstNode<MyAstContext> {} 
      public class     prependAstNode : AstNode<MyAstContext> {} 
      public class     appendAstNode : AstNode<MyAstContext> {}  
      public class     insertAtAstNode : AstNode<MyAstContext> {}  
      public class     intersectionAstNode : AstNode<MyAstContext> {} 
      public class     unionAstNode : AstNode<MyAstContext> {} 
      public class     asBagAstNode : AstNode<MyAstContext> {} 
      public class     asSequenceAstNode : AstNode<MyAstContext> {} 
      public class     asOrderdSetAstNode : AstNode<MyAstContext> {} 
      public class     asSetAstNode : AstNode<MyAstContext> {} 
      public class     flattenAstNode : AstNode<MyAstContext> {} 
      public class     subSequenceAstNode : AstNode<MyAstContext> {} 
      public class     andExpAstNode : AstNode<MyAstContext> {} 
      public class     orExpAstNode : AstNode<MyAstContext> {} 
      public class     notExpAstNode : AstNode<MyAstContext> {} 
      public class     xorExpAstNode : AstNode<MyAstContext> {} 
Mar 30, 2013 at 4:16 PM
public class     impliesExpAstNode : AstNode<MyAstContext> {} 
          public class     binaryOperatorAstNode : AstNode<MyAstContext> {}  
          public class     comparisonOperatorAstNode : AstNode<MyAstContext> {} 
          public class     arithmaticOperatorAstNode : AstNode<MyAstContext> {} 
          public class     oclInvExpAstNode : AstNode<MyAstContext> {} 
          public class     emofInvExpAstNode : AstNode<MyAstContext> {} 
          public class     operationContextExpAstNode : AstNode<MyAstContext> {} 
          public class     attributeContextExpAstNode : AstNode<MyAstContext> {}  
          public class     classContextExpAstNode : AstNode<MyAstContext> {} 
          public class     classContextSignatureAstNode : AstNode<MyAstContext> {} 
          public class     attributeContextbodyAstNode : ListNode<MyAstContext> {} 
          public class     attributeContextbodyItemAstNode : AstNode<MyAstContext> {} 
          public class     deriveExpAstNode : AstNode<MyAstContext> {} 
          public class     initExpAstNode : AstNode<MyAstContext> {} 
          public class     operationContextBodyExpsAstNode : ListNode<MyAstContext> {} 
          public class     operationContextSignatureAstNode : AstNode<MyAstContext> {} 
          public class     operationContextBodyItemAstNode : AstNode<MyAstContext> {} 
          public class     preConditionAstNode : AstNode<MyAstContext> {} 
          public class     postConditionAstNode : AstNode<MyAstContext> {} 
          public class     bodyExpAstNode : AstNode<MyAstContext> {} 
          public class     iterateExpAstNode : AstNode<MyAstContext> {} 
          public class     productExpAstNode : AstNode<MyAstContext> {} 
          public class     tupleExpAstNode : AstNode<MyAstContext> {} 
          public class     rejectExpAstNode : AstNode<MyAstContext> {} 
          public class     collectionTypeAstNode : AstNode<MyAstContext> {} 
          public class     tuplElementListAstNode : ListNode<MyAstContext> {} 
          public class     tupleElementAstNode : AstNode<MyAstContext> {} 
          public class     binaryBooleanOperatorAstNode : AstNode<MyAstContext> {} 
          public class     structuralExpAstNode : AstNode<MyAstContext> {} 
          public class     setLiteralExpAstNode : AstNode<MyAstContext> {} 
          public class     bagLiteralAstNode : AstNode<MyAstContext> {} 
          public class     orderedSetLiteralAstNode : AstNode<MyAstContext> {} 
          public class     sequenceLiteralAstNode : AstNode<MyAstContext> {} 
          public class     tupleLiteralAstNode : AstNode<MyAstContext> {} 
          public class     literalListAstNode : AstNode<MyAstContext> {} 
          public class     iteratorListAstNode : ListNode<MyAstContext> {} 
          public class     iteratorInitializationListAstNode : ListNode<MyAstContext> {} 
          public class     iteratorInitializationAstNode : AstNode<MyAstContext> {} 
          public class     collectionValueAstNode : AstNode<MyAstContext> {} 
          public class     parameterListAstNode : ListNode<MyAstContext> {} 
          public class     ArrayTypeAstNode : AstNode<MyAstContext> {} 
          public class     oclIsTypeOfAstNode : AstNode<MyAstContext> {} 
          public class     typedValueExpAstNode : AstNode<MyAstContext> {} 
          public class     unTypedValueExpAstNode : ListNode<MyAstContext> {} 
          public class     instanceMemberAccessAstNode : AstNode<MyAstContext> {} 
          public class     instanceMathodAccessAstNode : AstNode<MyAstContext> {}  
         

}
Mar 30, 2013 at 4:25 PM
rivantsov

Thanks for your response I have put the entire grammar above please help me to find out what is going wrong.

Nadvi
Mar 30, 2013 at 11:30 PM
I have seen that if I remove

instanceMemberAccess

from unTypedValueExp the being crashed is stopped.
  unTypedValueExp.Rule = booleanValueCollection
                                       |ToTerm("false")|ToTerm("true")
                                   |collectionValue
                                   |tupleLiteral
                                   |singleValueCollectionMember
                                   |collectionValueExp
                                       |iterateExp
                                       |stringLiteral
                                       |charLiteral
                                       |number
                                       |self
                                       |oclIsTypeOf
                                       |unTypedValueExp+lpar+parameterList+rpar
                                   |instanceMemberAccess
                                       |instanceMathodAccess
                                       |ToTerm("-")+number;
Coordinator
Mar 31, 2013 at 5:31 PM
please share full grammar as one text file - too much trouble to merge all these pieces
use ge.tt - one way to do it easily
Mar 31, 2013 at 5:59 PM
As-Salam-wa-alicum

I have uploaded the grammar file SLAang

With regards
Nadvi
Coordinator
Mar 31, 2013 at 6:33 PM
immediately hit this:

parameterList.Rule = MakeStarRule(parameterList,comma,valueExp)|ifThenElseExp;

this is abs wrong thing to do - MakeStarRule result should NOT be messed up with anything on assignment
Find all places like these and fix
Mar 31, 2013 at 6:42 PM
Thank you for quick response

I have done
parameterList.Rule = MakeStarRule(parameterList,comma,expression);

but no change.

With regards
Nadvi
Coordinator
Mar 31, 2013 at 6:56 PM
you have another case here:
  argumentList.Rule = MakePlusRule(argumentList, comma, variableDiclaration) | Empty;
just change it to MakeStarRule
About the grammar - too many external dependencies, it's not runnable for me. Please refactor into a single compilable file/class. In general, it is a good practice to start with straight grammar-only stuff, make sure it works, and then add AST/execution stuff - but in such a way that it can be easily pushed-out, and have back grammar-only file
Mar 31, 2013 at 8:59 PM
As-Salam-wa-alicum

Sir,


Thank you for your advice.

I changed according to your advice but no change .

I uploaded the grammar file and the source file to be parsed both are open able by notepad. The link is Grammar and source

With regards
Nadvi
Mar 31, 2013 at 9:18 PM
As-Salam-wa-alicum

I have an observation . The non terminal fullType and instanceMemberAccess is as follows

fullType -> Identifier :: fullType
fullType -> Identifier

instanceMemberAccess -> instanceMemberAccess . Identifier
instanceMemberAccess -> Identifier

but in parser state S498 and S522
fullType -> Identifier · [.]
instanceMemberAccess -> Identifier · [. ( -> > < >= <= <> = / div * + - and or xor implies )]
My question is why is the lookahead [.] for fullType.

With regards
Nadvi
Coordinator
Mar 31, 2013 at 11:26 PM
here's my findings:
  1. Has valueExp and ValueExp - is it intentional?!
  2. Need to register div, implies as op:
    RegisterOperators(12, "div", "implies");
  3. Add PreferShift in variableDeclaration:
    variableDiclaration.Rule = identifier + PreferShiftHere() + colon + type;
then grammar has no conflicts. It fails to parse your large file, smth to do with "::" double-colon separated lists, work on this
I did NOT encounter any Irony parser crashes as you reported at the beginning of this thread. Do you still have them? It can be connected to these Make-list fixes..
Roman
Coordinator
Apr 1, 2013 at 4:13 AM
answering your previous question, about [.] lookahead. Lookaheads are symbols that might appear AFTER the expression, so they mostly come from other Rules that use the non-terminal, not from the rule of NT itself. So for fullType, the dot comes from some other rule(s) that use fulltype - find them, analyze, and you'll probably find it.
Apr 1, 2013 at 5:13 PM
As-Salam-Wa-alicum

Sir,

Thank you very much for spending your valuable time for me. I apologies for my unintentional mistake.For removing TypedNonterminal I ran a replace operation which replaced the tyed from typedValueEx.I have register

RegisterOperators(6, "*", "/", "div");
RegisterOperators(15, "implies")

and changed variableDiclaration according to your advice.

Please give me a guidance on working on "::" double-colon.

With regards
Nadvi
Coordinator
Apr 2, 2013 at 6:35 AM
Wa-alicum-As-Salam
Well, not sure when I can get to this. Look at grammar rules, are missing anything around this :: symbol? It might be also the consequence of all these PreferShiftHere() and ReduceThis() hints you sprinkled everywhere. These hints effectively hide the conflict, telling the parser to use one alternative, always. And the error case you see might be in fact suppressed alternative.
Roman
Apr 18, 2013 at 11:32 PM
As-Salam-wa-alicum

Sir,

Thank you very much for your advice and by that I can remove the grammar errors but the "Fatal error in code colorizer.Colorizing has been disabled" comes again.
Please help me to find-out what mistake I have done here.I have removed 2 Make List rule by recursion and they work well.

I have uploaded DebugLog.xml which records the exception,stacktrace and tokens.I also have uploaded the grammar file and the test file at Files.

The summary of the exception is _shiftAction.NewState is null at Irony.Parsing.PrecedenceBasedParserAction.ToString().
The concern is why it is null for a specific case and how to make it not null from grammar.

Thank you very much again for reading my mail by spending your valuable time.

With regards
Nadvi
Coordinator
Apr 19, 2013 at 7:31 AM
no problem, will try to look at it soon, maybe on weekend, sorry can't promise immediate response
Apr 22, 2013 at 3:20 AM
As-Salam-wa-alicum

Sir,

Thank you very much for quick response.For pinpointing the problem I further debugged and get the following output
<Looging threadName = "" threadId = "9">
<MethodStatus message = "Calling S416.BuilderData.GetNextState(.) 
                                         from Irony.Parsing.PrecedenceHint.Apply(Irony.Parsing.LanguageData, 
                                            instanceName - gt  Identifier ·)" threadName = "" threadId = "9" />
<MethodStatus message = "newState is null" threadName = "" threadId = "9" />
<MethodStatus message = "ReduceItem is:instanceName - gt  Identifier " threadName = "" threadId = "9" />
<MethodStatus message = "Calling S573.BuilderData.GetNextState(.) 
                                          from Irony.Parsing.PrecedenceHint.Apply(Irony.Parsing.LanguageData, 
                                            instanceName - gt  Identifier ·)" threadName = "" threadId = "9" />
<MethodStatus message = "newState is null" threadName = "" threadId = "9" />
<MethodStatus message = "ReduceItem is:instanceName - gt  Identifier " threadName = "" threadId = "9" />
</Looging>
The related states are
State S416 (Inadequate)
  Reduce items:
    instanceName -> Identifier · [.]
    memberName -> Identifier · [. -> > < >= <= <> = / div * + - and or xor implies pre body post } )
                                               then , endif else in | init derive primitive enumeration 
                                               class abstract context package inv invariant def Identifier component endpackage]
    functionName -> Identifier · [(]
  Transitions: 

State S573 (Inadequate)
  Reduce items:
    instanceName -> Identifier · [.]
    memberName -> Identifier · [. -> > < >= <= <> = / div * + - and or xor implies pre body post } )
                                               then , endif else in | init derive primitive enumeration
                                               class abstract context package inv invariant def Identifier component endpackage]
  Transitions: 
The summary is from high level the problematic grammar rules are
             instanceName.Rule = identifier;
            memberName.Rule = identifier;
Now the concern is the rules works in others state like S151 well
State S151 (Inadequate)
  Reduce items:
    objectType -> Identifier · [::]
    instanceName -> Identifier · [. -> > < >= <= <> = / div * + - and or xor implies pre body post inv 
                                              invariant def Identifier component } primitive 
                                              enumeration   class abstract context package
                                              endpackage ) then , endif else in | init derive]
    functionName -> Identifier · [(]
  Transitions: 
please help me here to find out the problem in the rule.

With regards
Nadvi
Coordinator
Apr 22, 2013 at 8:29 AM
Ok, finally got to it. First, there were a few compile errors in grammar - missing non-terminal declarations (typedValueExp, unTypedValueExp), added these. Then reproduced the exception that disables the colorizer- it appears a bug: Precedence hint tried to fix the conflict in places where it is unfixable. I fixed the bug (added some validation code) and pushed sources - get latest, not zip but Sources from Mercurial.
The added code in fix brings 2 extra conflicts in grammar. They appear to come from the problematic rules that you mention - for instanceName and memberName. The problem here is that all these names are 'identical' for parser; they are introduced in formal grammar description to clarity (of explanation) but they bring conflict to LALR parser. Remove memberName, instanceName non-terminals from grammar and replace all occurrences in rules with 'identifier'. Find all other rules that similarly introduce just alias for another term, like memberName - this brings conflict. Fix all these rules.
And without without fixing these conflicts, parsing of sample fails. Another thing - do not register 'dot' as operator. Don't do things just to make conflicts go away - fix them for real!
Roman
Apr 23, 2013 at 12:34 AM
As-Salam-wa-alicum

Sir,

Thank you very much for fixing the error .Would you like to advice me on how can I clarify the grammar because after parsing when I process the parse tree or abstract syntax tree it hep me to do by traversing .

Thank you very much again for reading my mail by spending your valuable time and fixing the error quickly .

With regards
Nadvi
Apr 23, 2013 at 2:35 AM
As-Salam-wa-alicum

Sir,

If I remove dot from operator registration I get 8 conflict please help me here .

l uploaded the grammar file at SLAng Grammar

Thank you very much again for reading my mail by spending your valuable time.

With regards
Nadvi
Coordinator
Apr 24, 2013 at 8:42 AM
looking into this
Apr 24, 2013 at 9:02 AM
As-Salam-wa-alicum

Sir,

May be the link is missing.

Thank you for response.

With regards
Nadvi
Coordinator
Apr 24, 2013 at 5:52 PM
no, nothing is missing, what I meant is that I'm working on it, expect response soon
Coordinator
Apr 24, 2013 at 9:43 PM
here's fixed version:
http://ge.tt/94592ye/v/0?c
Coordinator
Apr 24, 2013 at 9:46 PM
Edited Apr 24, 2013 at 9:59 PM
Now some comments
  1. The biggest problem is compound identifier lists - identifiers or function calls connected with dots: 'foo.Bar(x).prop' More problems come from other similar lists with delimiters "::" and "->" instead of dot. This is a kinda known problem (same happens in c#), attempt to define exact definitions of each list separately brings a lot of conflicts. So the solution is to define one generic list that covers all variations, let it parse, and then verify after parsing that the parsed list is valid for the place in the source. I defined such list as chainedSequenceExt - it is a sequence of identifiers or function calls, optionally starting with "::", delimited by "::", "." or "->", and ending with array spec (like [number]). Here is the definition:
      var sequenceDelimiter = new NonTerminal("sequenceDelimiter"); //dot, ::,  ->
      var chainedSequence = new NonTerminal("chainedSequence");
      var chainedSequenceExt = new NonTerminal("chainedSequenceExt"); 
      var sequenceMember = new NonTerminal("sequenceMember");
      var arrayDim = new NonTerminal("arrayDim");
      var arraySpecOpt = new NonTerminal("arraySpecOpt");

      sequenceMember.Rule = identifier | functionCall;
      sequenceDelimiter.Rule = dot | scopeIn | propertyIs; // . :: ->
      chainedSequence.Rule = MakePlusRule(chainedSequence, sequenceDelimiter, sequenceMember); 
      arrayDim.Rule = "*" | identifier | number | number + comma + number | number + comma + "*";
      arraySpecOpt.Rule = Empty | "[" + arrayDim + "]";
      // Note: defining scopeInOpt (with rule: Empty|scopeIn) - does not work. 
      chainedSequenceExt.Rule = scopeIn + chainedSequence + arraySpecOpt | chainedSequence + arraySpecOpt;
Use it in all places instead of objectType, customType, etc. I did not remove these, just reassigned them (like 'var customType = chainedSequenceExt;') - cleanup all these. There are many terms and nonTerminals now declared but not used anymore - clean this up.
And remember - you need to add after-parse verification of the chainedSequenceExt lists.

Note that in most places (like in expression argument), a single identifier is in fact a primitive case of chainedSequenceExt; so if you have already included chainedSequenceExt as an alternative of some rule, do not include identifier - it will bring conflict, because parser does not know which to use to interpret a single identifier.
  1. Your other trouble comes from the attempt to define concrete function names in grammar (like 'collect', 'insertAt'), and to define rules for using them explicitly. This messes up things completely. Do not do this, they are just function calls, so let them be parsed as this. Recognize them as special, built-in methods when analysing the parse tree. I removed/disabled all these special function definitions
    After this all conflicts are gone. The grammar now 'defines' a broader language, so it must be supplemented with after grammar checks - do it.
  2. Had to bring dot as operator back. It appears you allow dot to be applied to expressions, like:
    (t - startDate.inMs()).round()

    so added dot to binaryOperator and set to highest prec value
  3. Now have a parse error, unexpected ";" symbol here, right after 'Schedule'
  schedule->iterate(s : Schedule ; 
                    next : Schedule = schedule->any(true) |
                    if next.nextStartDate(t) = -1   
I did not find ";" symbol defined anywhere in grammar, so this is something missing or not implemented yet.
Apr 25, 2013 at 3:51 AM
As-Salam-wa-alicum

Sir,

Thank you very much . You are working hard for this. In my thesis I will acknowledge you.Actually you removed the iterateExp that's why these lines are not parsed.I have add the code to functionCallArgs but stile it gives parser error.Invalid character ';' but in immediate previous grammar it was parse able.Please help me here.From this grammar it seems to me that after parsing a lot of work has to do. To avoid the work I explicitly define the expressions .

I uploaded the grammar at SLAng grammar

Thank you very much again for reading my mail by spending your valuable time and working on it.

With regards
Nadvi
Coordinator
Apr 26, 2013 at 6:16 PM
Man, it's time to take over the thing, rollup your sleeves and start pushing it. I've fixed all the conflicts (the most serious ones), so now you can move in small increments. Just start modifying this parameter definition when it is a 'lambda' to bring back the old code I removed - as far as I understand this is the problem now
Try it, read something about LALR parsing and about conflicts, try it again. Let me know if you're stuck
Roman
May 12, 2013 at 4:10 PM
As-Salam-wa-alicum

Sir,

Thank you very much for your effort but the way you advice need so many work at comiletime to determine the actual thing because of its generality
and it is possible to make it a little more specific.I did it but when I try to refactor emofAttributeDiclaration,functionSignatureBody and ArrayType so
many conflict come.Please help me here.My grammar file and the test file is here By the way do you have the original grammar
file on which you do work to fix conflict?

Thank you very much again for reading my mail by spending your valuable time and working on it.

With regards
Nadvi
Coordinator
May 14, 2013 at 10:24 PM
hi
sorry, do not have much time right now, it would be a few days
Roman
Coordinator
May 28, 2013 at 5:05 AM
Edited May 28, 2013 at 9:58 PM
Hi
Looking at your grammar, and at OCL spec (http://www.omg.org/spec/OCL/ISO/19507/PDF)
One conflict is
Reduce-reduce conflict. State S418, lookaheads: ). Selected reduce on first production in conflict set.

The conflict is coming from these 2 productions in state S418

functionCall -> Identifier ( ·parameterList )
collect -> valueExp . Identifier ( ·argumentList )

(The actual conflict is for empty lists inside parenthesis, parser does not know how to treat it - as empty parameterList or argumentList)
Now, looking at the language spec, section 7.7.2, subsection shorthand for collect - can't quite match it... shouldn't it be parameterList instead of argumentList?
ArgumentList consists of var declarations like 'var + : + type' , and I don't find anything like this in the spec - but paramList is there.
When I change to parameterList in the grammar, the conflict goes away
Coordinator
May 28, 2013 at 5:07 AM
another thing: bagLiteral has empty name in grammar code
Jun 2, 2013 at 9:20 PM
Edited Jun 2, 2013 at 9:25 PM
As-Salam-wa-alicum

Sir,

Thank you very much for your effort and thats are very helpful.I get another shift-reduce conflicts with the

attributeModifir.Rule = ToTerm("component") | Empty;

please help me here.I have uploaded the grammar code here.

Thank you very much again for reading my mail by spending your valuable time and working on it.

With regards
Nadvi