Пример #1
0
 void Imperative_ifstmt(out Node node)
 {
     DesignScript.Parser.Imperative.IfStmtNode ifStmtNode = new DesignScript.Parser.Imperative.IfStmtNode();
     List<Node> body = null;
     Expect(32);
     ifStmtNode.Col = t.col; ifStmtNode.Line = t.line;
     ifStmtNode.KeywordPos.setValue(t.col, t.line, t.val);
     if (la.val == "(") ifStmtNode.OpenParenPos.setValue(la.col, la.line, la.val);
     Expect(9);
     Imperative_expr(out node);
     ifStmtNode.IfExprNode = node;
     if (la.val == ")" && ifStmtNode.OpenParenPos.Value != null)
     ifStmtNode.CloseParenPos.setValue(la.col, la.line, la.val);
     else if (la.val != ")") ifStmtNode.OpenParenPos.Value = null;
     Expect(10);
     if (la.kind == 50) {
     if (la.val == "{")  ifStmtNode.OpenCurlyBracePos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = la.col, Line = la.line, Value = la.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
     Get();
     Imperative_stmtlist(out body);
     ifStmtNode.IfBody = body;
     if (la.val == "}" && ifStmtNode.OpenCurlyBracePos != null)  ifStmtNode.CloseCurlyBracePos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = la.col, Line = la.line, Value = la.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };  else if (la.val != "}") ifStmtNode.OpenCurlyBracePos = null;
     Expect(51);
     } else if (StartOf(8)) {
     Node singleStmt = null;
     Imperative_stmt(out singleStmt);
     ifStmtNode.IfBody.Add(singleStmt);
     } else SynErr(113);
     while (la.kind == 33) {
     DesignScript.Parser.Imperative.ElseIfBlock elseifBlock = new DesignScript.Parser.Imperative.ElseIfBlock();
     Get();
     elseifBlock.Col = t.col; elseifBlock.Line = t.line;
     elseifBlock.KeywordPos.setValue(t.col, t.line, t.val);
     if (la.val == "(") elseifBlock.OpenParenPos.setValue(la.col, la.line, la.val);
     Expect(9);
     Imperative_expr(out node);
     elseifBlock.Expr = node;
     if (la.val == ")" && elseifBlock.OpenParenPos.Value != null) elseifBlock.CloseParenPos.setValue(la.col, la.line, la.val); else if (la.val != ")") elseifBlock.OpenParenPos.Value = null;
     Expect(10);
     if (la.kind == 50) {
         if (la.val == "{") elseifBlock.OpenCurlyBracePos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = la.col, Line = la.line, Value = la.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
         Get();
         Imperative_stmtlist(out body);
         elseifBlock.Body = body;
         if (la.val == "}" && elseifBlock.OpenCurlyBracePos != null) elseifBlock.CloseCurlyBracePos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = la.col, Line = la.line, Value = la.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode }; else if(la.val != "}") elseifBlock.CloseCurlyBracePos.Value = null;
         Expect(51);
     } else if (StartOf(8)) {
         Node singleStmt = null;
         Imperative_stmt(out singleStmt);
         elseifBlock.Body.Add(singleStmt);
     } else SynErr(114);
     ifStmtNode.ElseIfList.Add(elseifBlock);
     }
     if (la.kind == 34) {
     Get();
     ifStmtNode.ElsePos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.KeywordNode };
     if (la.kind == 50) {
         if (la.val == "{") ifStmtNode.ElseOpenCurlyBracePos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = la.col, Line = la.line, Value = la.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
         Get();
         Imperative_stmtlist(out body);
         ifStmtNode.ElseBody = body;
         if (la.val == "}" && ifStmtNode.ElseOpenCurlyBracePos != null) ifStmtNode.ElseCloseCurlyBracePos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = la.col, Line = la.line, Value = la.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode }; else if (la.val != "}") ifStmtNode.ElseOpenCurlyBracePos = null;
         Expect(51);
     } else if (StartOf(8)) {
         Node singleStmt = null;
         Imperative_stmt(out singleStmt);
         ifStmtNode.ElseBody.Add(singleStmt);
     } else SynErr(115);
     }
     node = ifStmtNode;
 }
Пример #2
0
        void Assoc_FunctionalStatement(out Node node, ref DesignScript.Parser.Associative.IDEHelpNode Endline)
        {
            DesignScript.Parser.Associative.BinaryExpressionNode expressionNode = new DesignScript.Parser.Associative.BinaryExpressionNode();
            while (!(StartOf(5))) {SynErr(85); Get();}
            Node leftNode = null;
            isLeft = true;
            Assoc_DecoratedIdentifier(out leftNode);
            expressionNode.Line = leftNode.Line; expressionNode.Col = leftNode.Col; expressionNode.LeftNode = leftNode;
            isLeft = false;
            node = leftNode;
            if(!(leftNode is DesignScript.Parser.Associative.PostFixNode)) {
            Expect(53);
            Node rightNode = null;
            if (t.val == "=") { expressionNode.op.SetValue(t.val, t.line, t.col); }
            else { expressionNode.op.SetValue(null, 0, 0); }

            if (la.val == "[") {
            Assoc_LanguageBlock(out rightNode);
            Endline = null;
            } else if (HasMoreAssignmentStatements()) {
            Assoc_FunctionalStatement(out rightNode, ref Endline);
            } else if (!IsModifierStack()) {
            Assoc_Expression(out rightNode);
            while (!(la.kind == 0 || la.kind == 20)) {SynErr(86); Get();}
            Expect(20);
            if(t.val == ";") Endline.SetValue(t.val, t.line, t.col); else Endline.SetValue(null, -1, -1);
            } else if (IsModifierStack()) {
            DesignScript.Parser.Associative.ModifierStackNode mstack = new DesignScript.Parser.Associative.ModifierStackNode();
            if (la.val == "{") { mstack.openSharpBrace.SetValue(la.val, la.line, la.col); mstack.Line = la.line; mstack.Col = la.col; }
            else { 	mstack.openSharpBrace.SetValue(null, 0, 0); }

            Expect(50);
            string name = null;
            DesignScript.Parser.Associative.BinaryExpressionNode expression = new DesignScript.Parser.Associative.BinaryExpressionNode(); ; Node expression2 = null;
            Assoc_Expression(out expression2);
            if (la.kind == 55) {
                string _arr = null; int _line = 0; int _col = 0;
                Get();
                if (t.val == "=>") _arr = t.val; _line = t.line; _col = t.col;
                Expect(1);
                if (t.kind == _ident) { name = t.val; mstack.AddArrow(_arr, _line, _col, t.val, t.line, t.col); } else { name = null; mstack.AddArrow(_arr, _line, _col, null, 0, 0); }
            }
            expression.LeftNode = leftNode;
            expression.op = expressionNode.op;
            expression.RightNode = expression2;
            mstack.AddElementNode(expression, name);

            while (!(la.kind == 0 || la.kind == 20)) {SynErr(87); Get();}
            Expect(20);
            if (t.val == ";") mstack.AddEndLine(t.val, t.line, t.col); else mstack.AddEndLine(null, 0, 0);
            while (StartOf(6)) {
                name = null;
                bool bHasOperator = false; expression = new DesignScript.Parser.Associative.BinaryExpressionNode(); expression2 = null;
                bHasOperator = true; DesignScript.Parser.Associative.IDEHelpNode IDEop = expression.op;
                if (StartOf(7)) {
                    Assoc_BinaryOps(ref IDEop);
                }
                Assoc_Expression(out expression2);
                if (la.kind == 55) {
                    string _arr = null; int _line = 0; int _col = 0;
                    Get();
                    if (t.val == "=>") _arr = t.val; _line = t.line; _col = t.col;
                    Expect(1);
                    if (t.kind == _ident) { name = t.val; mstack.AddArrow(_arr, _line, _col, t.val, t.line, t.col); } else { name = null; mstack.AddArrow(_arr, _line, _col, null, 0, 0); }
                }
                if(!bHasOperator)
                {
                expression.RightNode = expression2;
                expression.LeftNode = leftNode;
                expression.op = expressionNode.op;
                mstack.AddElementNode(expression, name);
                }
                else
                {
                expression.LeftNode = leftNode;
                DesignScript.Parser.Associative.BinaryExpressionNode expression3 = new DesignScript.Parser.Associative.BinaryExpressionNode();
                expression3.LeftNode = leftNode;
                expression3.op = IDEop;
                expression3.RightNode = expression2;
                expression.LeftNode = leftNode;
                expression.RightNode = expression3;
                expression.op = expressionNode.op;
                mstack.AddElementNode(expression, name);
                }

                Expect(20);
                if (t.val == ";") mstack.AddEndLine(t.val, t.line, t.col); else mstack.AddEndLine(null, 0, 0);
            }
            if (la.val == "}" && mstack.openSharpBrace.Value != null) mstack.closeBrace.SetValue(la.val, la.line, la.col); else if (la.val != "}") mstack.openSharpBrace.SetValue(null, 0, 0); rightNode = mstack;
            Expect(51);
            } else SynErr(88);
            expressionNode.RightNode = rightNode; node = expressionNode;
                                      if (rightNode is DesignScript.Parser.Associative.ExprListNode) {
                                          DesignScript.Parser.Associative.IdentifierNode identNode =
                                              expressionNode.LeftNode as DesignScript.Parser.Associative.IdentifierNode;
                                          if (null != identNode) {
                                              DesignScript.Parser.Associative.IDEHelpNode identValue = identNode.IdentValue;
                                              rightNode.Name = ((null != identValue) ? identValue.Value : null);
                                          }
                                      }
                                  }
        }
Пример #3
0
        void Assoc_FunctionDecl(out Node node)
        {
            codeSegmentStarted = true;
            DesignScript.Parser.Associative.FunctionDefinitionNode f = null;
            f = new DesignScript.Parser.Associative.FunctionDefinitionNode()
            {
               Line = la.line,
               Col = la.col
            };

            if (la.kind == 26) {
            Get();
            if (t.val == "external")
               f.Kwexternal.SetValue(t.val, t.line, t.col);

            if (la.kind == 22) {
                Get();
                if (t.val == "native")
                   f.Kwnative.SetValue(t.val, t.line, t.col);

            }
            Assoc_ExternalLibraryReference(ref f);
            }
            Expect(25);
            if (t.val == "def")
               f.Kwdef.SetValue(t.val, t.line, t.col);
            else
               Get();

            DesignScript.Parser.Associative.IDEHelpNode IdentName = f.name;
            DesignScript.Parser.Associative.TypeNode IDEType = new DesignScript.Parser.Associative.TypeNode();

            DesignScript.Parser.Associative.ArgumentSignatureNode argumentSignature = null;
            DesignScript.Parser.Associative.Pattern pattern = null;

            Assoc_MethodSignature(out argumentSignature, out pattern, ref IdentName, ref IDEType);
            f.IDEReturnType = IDEType;
            f.name = IdentName;
            f.Pattern = pattern;
            f.Singnature = argumentSignature;

            while (!(StartOf(3))) {SynErr(76); Get();}
            Node functionBody = null;
            if (la.kind == 20) {
            Get();
            f.endLine.SetValue(t.val, t.line, t.col);
            } else if (la.kind == 53) {
            Get();
            DesignScript.Parser.Associative.CodeBlockNode func = new DesignScript.Parser.Associative.CodeBlockNode();
            DesignScript.Parser.Associative.BinaryExpressionNode binaryExpr = new DesignScript.Parser.Associative.BinaryExpressionNode();
            binaryExpr.op.SetValue(t.val, t.line, t.col);
            Node expr;

            Assoc_Expression(out expr);
            binaryExpr.RightNode = expr;
            List<Node> body = new List<Node>();
            body.Add(binaryExpr);
            func.Body = body;
            f.FunctionBody = func as DesignScript.Parser.Associative.CodeBlockNode;

            Expect(20);
            f.endLine.SetValue(t.val, t.line, t.col);

            } else if (la.kind == 50) {
            Assoc_FunctionalMethodBodyMultiLine(out functionBody);
            f.FunctionBody = functionBody as DesignScript.Parser.Associative.CodeBlockNode;
            } else SynErr(77);
            node = f;
        }
Пример #4
0
 void Assoc_DecoratedIdentifier(out Node node)
 {
     node = null;
     if (IsTypedVariable()) {
     Assoc_vardecl(out node);
     } else if (la.kind == 1 || la.kind == 9 || la.kind == 50) {
     Assoc_IdentifierList(out node);
     } else SynErr(97);
 }
Пример #5
0
 void Assoc_Factor(out Node node)
 {
     node = null;
     if (IsNumber()) {
     Assoc_Number(out node);
     } else if (la.kind == 47) {
     Get();
     node = new DesignScript.Parser.Associative.BooleanNode(){ value = t.val, Line = t.line, Col = t.col };
     } else if (la.kind == 48) {
     Get();
     node = new DesignScript.Parser.Associative.BooleanNode(){ value = t.val, Line = t.line, Col = t.col };
     } else if (la.kind == 49) {
     Get();
     node = new DesignScript.Parser.Associative.NullNode(){ value = t.val, Line = t.line, Col = t.col };
     } else if (la.kind == 5) {
     Assoc_Char(out node);
     } else if (la.kind == 4) {
     Assoc_String(out node);
     } else if (la.kind == 1 || la.kind == 9 || la.kind == 50) {
     Assoc_IdentifierList(out node);
     } else if (StartOf(17)) {
     Assoc_UnaryExpression(out node);
     } else if (la.kind == 7) {
     Assoc_LanguageBlock(out node);
     } else SynErr(101);
     if(IsReplicationGuideIdent()) {
     Assoc_ReplicationGuideIdent(ref node);
     }
 }
Пример #6
0
 void Assoc_Char(out Node node)
 {
     node = null;
     Expect(5);
     DesignScript.Parser.Associative.CharNode _node = null;
     if (t.val.Length <= 2) {
     errors.SemErr(t.line, t.col, "Empty character literal.");
     }
     if (t.kind == _char)
     {
     _node = new DesignScript.Parser.Associative.CharNode() { value = t.val};
     _node.IDEValue.SetValue(t.val, t.line, t.col);
     _node.Line = t.line;
     _node.Col = t.col;
     }
     node = _node;
 }
Пример #7
0
 void Assoc_ComparisonExpression(out Node node)
 {
     Assoc_RangeExpr(out node);
     while (StartOf(14)) {
     DesignScript.Parser.Associative.BinaryExpressionNode binaryNode = new DesignScript.Parser.Associative.BinaryExpressionNode();
     DesignScript.Parser.Associative.IDEHelpNode IDEop = binaryNode.op;
     Assoc_ComparisonOp(ref IDEop);
     binaryNode.op = IDEop;
     Node expr2 = null;
     Assoc_RangeExpr(out expr2);
     binaryNode.LeftNode = node; binaryNode.RightNode = expr2;
     node = binaryNode;
     }
 }
Пример #8
0
        void Imperative_RangeExpr(out Node node)
        {
            Imperative_rel(out node);
            if (la.kind == 21) {
            DesignScript.Parser.Imperative.RangeExprNode rnode = new DesignScript.Parser.Imperative.RangeExprNode();
            rnode.FromNode = node;
            rnode.Col = node.Col;
            rnode.Line = node.Line;

            Get();
            rnode.FirstRangeOpPos.setValue(t.col, t.line, t.val);
            Imperative_rel(out node);
            rnode.ToNode = node;
            if (!(t.val == "..")&&(la.val == "..")) {
            if (la.kind == 21) {
                RangeStepOperator op;
                Get();
                rnode.SecondRangeOpPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
                Imperative_rangeStepOperator(out op);
                if (op != RangeStepOperator.stepsize)
                {
                 rnode.StepOpPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
                }
                rnode.stepoperator = op;
                Imperative_rel(out node);
                rnode.StepNode = node;
            }
            }
            node = rnode;
            }
        }
Пример #9
0
 void Imperative_stmt(out Node node)
 {
     node = null;
     if (isFunctionCall()) {
     Imperative_functioncall(out node);
     Expect(20);
     DesignScript.Parser.Imperative.FunctionCallNode fcNode = node as DesignScript.Parser.Imperative.FunctionCallNode;
     fcNode.EndlinePos.setValue(t.col, t.line, t.val);
     node = fcNode;
     } else if (la.kind == 1 || la.kind == 9 || la.kind == 50) {
     Imperative_assignstmt(out node);
     } else if (la.kind == 32) {
     Imperative_ifstmt(out node);
     } else if (la.kind == 35) {
     Imperative_whilestmt(out node);
     } else if (la.kind == 36) {
     Imperative_forloop(out node);
     } else if (la.kind == 7) {
     Imperative_languageblock(out node);
     } else if (la.kind == 45) {
     Get();
     DesignScript.Parser.Imperative.BreakNode bnode = new DesignScript.Parser.Imperative.BreakNode();
     if (t.kind == _Kw_break) bnode.KwBreak.setValue(t.col, t.line, t.val);
     Expect(20);
     if (t.kind == _endline) bnode.EndLine.setValue(t.col, t.line, t.val);
     node = bnode;
     } else if (la.kind == 46) {
     Get();
     DesignScript.Parser.Imperative.ContinueNode cnode = new DesignScript.Parser.Imperative.ContinueNode();
     if (t.kind == _Kw_continue) cnode.KwContinue.setValue(t.col, t.line, t.val);
     Expect(20);
     if (t.kind == _endline) cnode.EndLine.setValue(t.col, t.line, t.val);
     node = cnode;
     } else if (la.kind == 20) {
     Get();
     DesignScript.Parser.Imperative.IDEHelpNode endlineNode = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
     node = endlineNode;
     } else SynErr(107);
 }
Пример #10
0
 void Imperative_num(out Node node)
 {
     node = null; DesignScript.Parser.Imperative.IntNode INode = new DesignScript.Parser.Imperative.IntNode();
     if (la.kind == 12 || la.kind == 57) {
     if (la.kind == 12) {
         Get();
         if (t.val == "-") INode.SignPos.setValue(t.col, t.line, t.val);
     } else {
         Get();
     }
     if (t.val == "+") INode.SignPos.setValue(t.col, t.line, t.val);
     }
     if (la.kind == 2) {
     Get();
     if (t.kind == _number) INode.IDEValue.setValue(t.col, t.line, t.val); node = INode;
     } else if (la.kind == 3) {
     Get();
     if (t.kind == _float) { DesignScript.Parser.Imperative.DoubleNode DNode = new DesignScript.Parser.Imperative.DoubleNode(); DNode.SignPos = INode.SignPos; DNode.IDEValue.setValue(t.col, t.line, t.val); node = DNode; }
     } else SynErr(129);
 }
Пример #11
0
 void Imperative_parenExp(out Node node)
 {
     Node exp = null; DesignScript.Parser.Imperative.ParenExpressionNode pNode = new DesignScript.Parser.Imperative.ParenExpressionNode();
     if (la.val == "(") pNode.openParen.setValue(la.col, la.line, la.val); else pNode.openParen.setValue(0, 0, null); pNode.Line = pNode.openParen.Line; pNode.Col = pNode.openParen.Col;
     Expect(9);
     Imperative_expr(out exp);
     pNode.expression = exp;
     if (la.val == ")" && pNode.openParen.Value != null) pNode.closeParen.setValue(la.col, la.line, la.val); else if (la.val != ")") pNode.openParen.setValue(0, 0, null);
     Expect(10);
     node = pNode;
 }
Пример #12
0
 void Imperative_NameReference(out Node node)
 {
     node = null;
     DesignScript.Parser.Imperative.ArrayNode array = null;
     if (la.kind == 9) {
     Imperative_parenExp(out node);
     } else if (la.kind == 1 || la.kind == 50) {
     if (isFunctionCall()) {
         Imperative_functioncall(out node);
     } else if (la.kind == 1) {
         Imperative_Ident(out node);
     } else {
         DesignScript.Parser.Imperative.ExprListNode exprlist = new DesignScript.Parser.Imperative.ExprListNode();
         if (la.val == "{") exprlist.OpenCurlyBracePos.setValue(la.col, la.line, la.val);
         Get();
         if (StartOf(18)) {
             Imperative_expr(out node);
             exprlist.list.Add(node);
             exprlist.Col = t.col;
             exprlist.Line = t.line;
             while (la.kind == 52) {
                 Get();
                 DesignScript.Parser.Imperative.IDEHelpNode commaPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
                 exprlist.ExprCommaPosList.Add(commaPos);
                 Imperative_expr(out node);
                 exprlist.list.Add(node);
             }
         }
         if (la.val == "}" && exprlist.OpenCurlyBracePos.Value != null) exprlist.CloseCurlyBracePos.setValue(la.col, la.line, la.val); else if (la.val != "}") exprlist.OpenCurlyBracePos.Value = null;
         Expect(51);
         node = exprlist;
     }
     } else SynErr(118);
     if (la.kind == 7) {
     Imperative_arrayIndices(out array);
     array.Ident = node; node = array;
     }
 }
Пример #13
0
        void Imperative_logicalexpr(out Node node)
        {
            node = null;
            Imperative_RangeExpr(out node);
            while (StartOf(14)) {
            Operator op;
            Imperative_relop(out op);
            DesignScript.Parser.Imperative.IDEHelpNode operatorPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
            Node rhsNode = null;
            Imperative_RangeExpr(out rhsNode);
            DesignScript.Parser.Imperative.BinaryExpressionNode bNode = new DesignScript.Parser.Imperative.BinaryExpressionNode();
            bNode.LeftNode = node;
            bNode.RightNode = rhsNode;
            bNode.Optr = op;
            bNode.Col = node.Col;
            bNode.Line = node.Line;
            bNode.OperatorPos = operatorPos;
            node = bNode;

            }
        }
Пример #14
0
        void Imperative_languageblock(out Node node)
        {
            node = null;
            DesignScript.Parser.Imperative.LanguageBlockNode langblock = new DesignScript.Parser.Imperative.LanguageBlockNode();

            if (la.val == "[") langblock.OpenParenPos.setValue(la.col, la.line, la.val);
            Expect(7);
            langblock.Col = t.col; langblock.Line = t.line;
            Expect(1);
            if (t.val == "Imperative" || t.val == "Associative") langblock.IdentPos.setValue(t.col, t.line, t.val);
            if( 0 == t.val.CompareTo("Imperative")) {
            langblock.CodeBlock.language = ProtoCore.Language.kImperative;
            }
            else if( 0 == t.val.CompareTo("Associative")) {
            langblock.CodeBlock.language = ProtoCore.Language.kAssociative;
            }

            while (la.kind == 52) {
            Get();
            string key;
            DesignScript.Parser.Imperative.IDEHelpNode commaPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
            langblock.ParaPosList.Add(commaPos);
            Expect(1);
            key = t.val;
            DesignScript.Parser.Imperative.IDEHelpNode identPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.IdentNode };
            langblock.ParaPosList.Add(identPos);
            Expect(53);
            DesignScript.Parser.Imperative.IDEHelpNode assignPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
            langblock.ParaPosList.Add(assignPos);
            Expect(4);
            DesignScript.Parser.Imperative.StringNode textstringPos = new DesignScript.Parser.Imperative.StringNode() { Col = t.col, Line = t.line, value = t.val };
            langblock.TextStringList.Add(textstringPos);
            if ("fingerprint" == key)
            {
            langblock.CodeBlock.fingerprint = t.val;
            langblock.CodeBlock.fingerprint = langblock.CodeBlock.fingerprint.Remove(0,1);
            langblock.CodeBlock.fingerprint = langblock.CodeBlock.fingerprint.Remove(langblock.CodeBlock.fingerprint.Length-1,1);
            }
            else if ("version" == key)
            {
            langblock.CodeBlock.version = t.val;
            langblock.CodeBlock.version = langblock.CodeBlock.version.Remove(0,1);
            langblock.CodeBlock.version = langblock.CodeBlock.version.Remove(langblock.CodeBlock.version.Length-1,1);
            }

            }
            if (la.val == "]" && langblock.OpenParenPos.Value != null) langblock.CloseParenPos.setValue(la.col, la.line, la.val); else if (la.val != "]") langblock.OpenParenPos.Value = null;
            Expect(8);
            if (la.val == "{") langblock.OpenCurlyBracePos.setValue(la.col, la.line, la.val);
            Expect(50);
            Node codeBlockNode = null;
            if (langblock.CodeBlock.language == ProtoCore.Language.kAssociative ) {
            Hydrogen(out codeBlockNode);
            } else if (langblock.CodeBlock.language == ProtoCore.Language.kImperative ) {
            Imperative(out codeBlockNode);
            } else SynErr(109);
            if (langblock.CodeBlock.language == ProtoCore.Language.kInvalid ) {
            int openCurlyBraceCount = 0, closeCurlyBraceCount = 0;
            DesignScript.Parser.Imperative.CodeBlockNode codeBlockInvalid = new DesignScript.Parser.Imperative.CodeBlockNode();
            while (closeCurlyBraceCount <= openCurlyBraceCount) {
                if (la.kind == 7) {
                    Imperative_languageblock(out codeBlockNode);
                    codeBlockInvalid.Body.Add(codeBlockNode);
                } else if (la.kind == 50) {
                    Get();
                    openCurlyBraceCount++;
                } else if (la.kind == 51) {
                    if (la.val == "}" && langblock.OpenCurlyBracePos.Value != null) langblock.CloseCurlyBracePos.setValue(la.col, la.line, la.val); else if(la.val != "}") langblock.OpenCurlyBracePos.Value = null;
                    Get();
                    closeCurlyBraceCount++;
                } else if (la.kind == 0) {
                    Get();
                    Expect(51);
                    break;
                } else if (true) {
                    Get();
                } else SynErr(110);
            }
            codeBlockNode = codeBlockInvalid;
            } else if (true) {
            if (la.val == "}" && langblock.OpenCurlyBracePos.Value != null) langblock.CloseCurlyBracePos.setValue(la.col, la.line, la.val); else if(la.val != "}") langblock.OpenCurlyBracePos.Value = null;
            Expect(51);
            } else SynErr(111);
            langblock.CodeBlockNode = codeBlockNode;
            node = langblock;
        }
Пример #15
0
 void Assoc_ArrayExprList(out Node node)
 {
     DesignScript.Parser.Associative.ExprListNode exprlist = new DesignScript.Parser.Associative.ExprListNode(); exprlist.Line = la.line; exprlist.Col = la.col;
     if (la.val == "{") exprlist.openBrace.SetValue(la.val, la.line, la.col);
     Expect(50);
     if (StartOf(9)) {
     Assoc_Expression(out node);
     exprlist.list.Add(node);
     while (la.kind == 52) {
         Get();
         exprlist.AddComma(t.val, t.line, t.col);
         Assoc_Expression(out node);
         exprlist.list.Add(node);
     }
     }
     if (la.val == "}" && exprlist.openBrace.Value != null) exprlist.closeBrace.SetValue(la.val, la.line, la.col); else if (la.val != "}") exprlist.openBrace.Value = null;
     Expect(51);
     node = exprlist;
 }
Пример #16
0
 void Imperative_String(out Node node)
 {
     node = null;
     Expect(4);
     DesignScript.Parser.Imperative.StringNode _node = null;
     node = new DesignScript.Parser.Imperative.StringNode();
     if (t.kind == _textstring)
     {
     _node = new DesignScript.Parser.Imperative.StringNode() { value = t.val };
     _node.IDEValue.setValue(t.line, t.col, t.val);
     _node.Line = t.line;
     _node.Col = t.col;
     }
     node = _node;
 }
Пример #17
0
 void Assoc_arrayIdent(out Node node)
 {
     Assoc_Ident(out node);
     DesignScript.Parser.Associative.IdentifierNode var = node as DesignScript.Parser.Associative.IdentifierNode;
     if (la.kind == 7) {
     DesignScript.Parser.Associative.ArrayNode array = null;
     Assoc_arrayIndices(out array);
     var.ArrayDimensions = array;
     }
 }
Пример #18
0
        void Imperative_term(out Node node)
        {
            node = null;
            Imperative_interimfactor(out node);
            while (la.kind == 58 || la.kind == 59 || la.kind == 60) {
            Operator op;
            Imperative_mulop(out op);
            DesignScript.Parser.Imperative.IDEHelpNode operatorPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
            Node rhsNode = null;
            Imperative_interimfactor(out rhsNode);
            DesignScript.Parser.Imperative.BinaryExpressionNode bNode = new DesignScript.Parser.Imperative.BinaryExpressionNode();
            bNode.LeftNode = node;
            bNode.RightNode = rhsNode;
            bNode.Optr = op;
            bNode.Col = node.Col;
            bNode.Line = node.Line;
            bNode.OperatorPos = operatorPos;
            node = bNode;

            }
        }
Пример #19
0
        void Assoc_ClassDecl(out Node node)
        {
            codeSegmentStarted = true;
            DesignScript.Parser.Associative.ClassDeclNode classnode;
            classnode = new DesignScript.Parser.Associative.ClassDeclNode()
            {
               Line = la.line,
               Col = la.col
            };

            if (la.val == "class") classnode.Kwclass.SetValue(la.val, la.line, la.col);
            Expect(23);
            if (la.kind == _ident) classnode.ClassName.SetValue(la.val, la.line, la.col);
            Expect(1);
            if (la.kind == 27) {
            if (la.kind == _kw_extend) classnode.Kwextend.SetValue(la.val, la.line, la.col);
            Get();
            if (la.kind == _ident) classnode.AddExt(la.val, la.line, la.col);
            Expect(1);
            if (la.kind == _ident) classnode.AddExt(la.val, la.line, la.col);
            while (la.kind == 1) {
                Get();
            }
            }
            if (la.val == "{") classnode.openBrace.SetValue(la.val, la.line, la.col);
            Expect(50);
            while (la.kind != _EOF && la.val != "}") {
            while (!(StartOf(4))) {SynErr(78); Get();}
            int kwstaticline = -1, kwstaticcol = -1;
            if (la.kind == 28 || la.kind == 29 || la.kind == 30) {
                classnode.AddAccessLabel(la.val, la.line, la.col);
                if (la.kind == 28) {
                    Get();
                } else if (la.kind == 29) {
                    Get();
                } else {
                    Get();
                }
            }
            if (la.kind == 44) {
                Get();
                if (t.kind == _Kw_static) kwstaticline = t.line; kwstaticcol = t.col;
            }
            if (la.kind == 24) {
                Node constr = null;
                Assoc_constructordecl(out constr);
                if (kwstaticline != -1)
                {
                   DesignScript.Parser.Associative.ConstructorDefinitionNode constrNode = null;
                   constrNode = (constr as DesignScript.Parser.Associative.ConstructorDefinitionNode);
                   if (null != constrNode)
                       constrNode.KwStatic.SetValue("static", kwstaticline, kwstaticcol);
                }

                classnode.funclist.Add(constr);

            } else if (la.kind == 1) {
                Node varnode = null;
                Assoc_vardecl(out varnode);
                classnode.varlist.Add(varnode);
                if (kwstaticline != -1)
                {
                   DesignScript.Parser.Associative.VarDeclNode varDeclNode = null;
                   varDeclNode = (varnode as DesignScript.Parser.Associative.VarDeclNode);
                   if (null != varDeclNode)
                       varDeclNode.KwStatic.SetValue("static", kwstaticline, kwstaticcol);
                }

                while (!(la.kind == 0 || la.kind == 20)) {SynErr(79); Get();}
                if (la.val == ";") classnode.AddVarDeclComma(la.val, la.line, la.col);
                Expect(20);
            } else if (la.kind == 25 || la.kind == 26) {
                Node funcnode = null;
                Assoc_FunctionDecl(out funcnode);
                if (kwstaticline != -1)
                {
                   DesignScript.Parser.Associative.FunctionDefinitionNode funcDefNode = null;
                   funcDefNode = (funcnode as DesignScript.Parser.Associative.FunctionDefinitionNode);
                   if (null != funcDefNode)
                       funcDefNode.KwStatic.SetValue("static", kwstaticline, kwstaticcol);
                }
                classnode.funclist.Add(funcnode);

            } else SynErr(80);
            }
            if (la.val == "}" && classnode.openBrace.Value != null)
               classnode.closeBrace.SetValue(la.val, la.line, la.col);
            else if (la.val != "}")
               classnode.openBrace.Value = null;

            Expect(51);
            node = classnode;
        }
Пример #20
0
 void Imperative_unaryexpr(out Node node)
 {
     DesignScript.Parser.Imperative.UnaryExpressionNode an = new DesignScript.Parser.Imperative.UnaryExpressionNode();
     node = null;
     if (StartOf(15)) {
     Imperative_NegExpression(out an);
     } else if (StartOf(16)) {
     Imperative_BitUnaryExpression(out an);
     } else SynErr(119);
     node = an;
 }
Пример #21
0
 void Assoc_constructordecl(out Node constrNode)
 {
     DesignScript.Parser.Associative.ConstructorDefinitionNode constr = new DesignScript.Parser.Associative.ConstructorDefinitionNode() { Line = la.line, Col = la.col };
     Expect(24);
     constr.Kwconstructor.SetValue(t.val, t.line, t.col);
     DesignScript.Parser.Associative.IDEHelpNode IdentName = constr.name; DesignScript.Parser.Associative.TypeNode IDEType = new DesignScript.Parser.Associative.TypeNode();
     DesignScript.Parser.Associative.ArgumentSignatureNode argumentSignature = null; DesignScript.Parser.Associative.Pattern pattern = null;
     Assoc_MethodSignature(out argumentSignature, out pattern,  ref IdentName, ref IDEType);
     constr.name = IdentName; constr.IDEReturnType = IDEType; constr.Pattern = pattern; constr.Signature = argumentSignature;
     if (la.kind == 54) {
     Get();
     constr.SetColonToken(t);
     Assoc_BaseConstructorCall(constr);
     }
     Node functionBody = null;
     Assoc_FunctionalMethodBodyMultiLine(out functionBody);
     constr.FunctionBody = functionBody as DesignScript.Parser.Associative.CodeBlockNode;
     constrNode = constr;
 }
Пример #22
0
 void Imperative_vardecl(out Node node)
 {
     DesignScript.Parser.Imperative.VarDeclNode varDeclNode = new DesignScript.Parser.Imperative.VarDeclNode();
     Expect(1);
     varDeclNode.Line = t.line; varDeclNode.Col = t.col; varDeclNode.name.setValue(t.col, t.line, t.val);
     if (t.kind == _ident) varDeclNode.name.setValue(t.col, t.line, t.val);
     if (la.kind == 54) {
     DesignScript.Parser.Imperative.TypeNode IDEType = new DesignScript.Parser.Imperative.TypeNode();
     Imperative_TypeRestriction(out IDEType);
     varDeclNode.IDEArgumentType = IDEType;
     }
     if (la.kind == 53) {
     Get();
     if (t.val == "=") varDeclNode.equal.setValue(t.col, t.line, t.val);
     Node rhsNode = null;
     Imperative_expr(out rhsNode);
     varDeclNode.NameNode = rhsNode;
     }
     node = varDeclNode;
 }
Пример #23
0
 void Assoc_Expression(out Node node)
 {
     node = null;
     Assoc_LogicalExpression(out node);
     while (la.kind == 56) {
     Assoc_TernaryOp(ref node);
     }
 }
Пример #24
0
 void Imperative_whilestmt(out Node node)
 {
     DesignScript.Parser.Imperative.WhileStmtNode whileStmtNode = new DesignScript.Parser.Imperative.WhileStmtNode();
     List<Node> body = null;
     Expect(35);
     whileStmtNode.Col = t.col; whileStmtNode.Line = t.line;
     whileStmtNode.KeywordPos.setValue(t.col, t.line, t.val);
     if (la.val == "(") whileStmtNode.OpenParenPos.setValue(la.col, la.line, la.val);
     Expect(9);
     Imperative_expr(out node);
     whileStmtNode.Expr = node;
     if (la.val == ")" && whileStmtNode.OpenParenPos.Value != null) whileStmtNode.CloseParenPos.setValue(la.col, la.line, la.val); else if (la.val != ")") whileStmtNode.OpenParenPos.Value = null;
     Expect(10);
     if (la.val == "{") whileStmtNode.OpenCurlyBracePos.setValue(la.col, la.line, la.val);
     Expect(50);
     Imperative_stmtlist(out body);
     whileStmtNode.Body = body;
     if (la.val == "}" && whileStmtNode.OpenCurlyBracePos.Value != null) whileStmtNode.CloseCurlyBracePos.setValue(la.col, la.line, la.val); else if (la.val != "}") whileStmtNode.OpenCurlyBracePos.Value = null;
     Expect(51);
     node = whileStmtNode;
 }
Пример #25
0
        void Assoc_FunctionalMethodBodyMultiLine(out Node funcBody)
        {
            DesignScript.Parser.Associative.CodeBlockNode functionBody = new DesignScript.Parser.Associative.CodeBlockNode();
            List<Node> body = new List<Node>();

            if (la.val == "{") functionBody.openBrace.SetValue(la.val, la.line, la.col); functionBody.Line = la.line; functionBody.Col = la.col;
            Expect(50);
            Assoc_StatementList(out body);
            functionBody.Body =body;
            if (la.val == "}" && functionBody.openBrace.Value != null) functionBody.closeBrace.SetValue(la.val, la.line, la.col); else if (la.val != "}") functionBody.openBrace.Value = null;
            Expect(51);
            funcBody = functionBody;
        }
Пример #26
0
        void Import_Statement(out Node node)
        {
            DesignScript.Parser.Associative.ImportNode importNode = null;
            importNode = new DesignScript.Parser.Associative.ImportNode();

            while (!(la.kind == 0 || la.kind == 41)) {SynErr(72); Get();}
            Expect(41);
            if (t.kind == _Kw_import) importNode.KwImport.SetValue(t.val, t.line, t.col);
            if (la.val == "(") importNode.OpenParen.SetValue(la.val, la.line, la.col);
            Expect(9);
            if (la.kind == 4) {
            Get();
            if (t.kind == _textstring) { DesignScript.Parser.Associative.StringNode path = new DesignScript.Parser.Associative.StringNode() { value = t.val, Line = t.line, Col = t.col }; importNode.Path = path; }
            } else if (la.kind == 1) {
            Get();
            if (t.kind == _ident) importNode.Identifier.SetValue(t.val, t.line, t.col);
            Expect(42);
            if (t.kind == _Kw_from) importNode.KwFrom.SetValue(t.val, t.line, t.col);
            Expect(4);
            if (t.kind == _textstring) { DesignScript.Parser.Associative.StringNode path = new DesignScript.Parser.Associative.StringNode() { value = t.val, Line = t.line, Col = t.col }; importNode.Path = path; }
            } else SynErr(73);
            if (la.val == ")" && importNode.OpenParen.Value != null) importNode.CloseParen.SetValue(la.val, la.line, la.col); else if (la.val != ")") importNode.OpenParen.Value = null;
            Expect(10);
            if (la.kind == 43) {
            Get();
            if (t.kind == _Kw_prefix) importNode.KwPrefix.SetValue(t.val, t.line, t.col);
            Expect(1);
            if (t.kind == _ident) importNode.PrefixIdent.SetValue(t.val, t.line, t.col);
            }
            Expect(20);
            if (t.val == ";")
               importNode.EndLine.SetValue(t.val, t.line, t.col);
            else
            {
               if (null != importNode.OpenParen)
               importNode.OpenParen.SetValue(string.Empty, -1, -1);
               if (null != importNode.CloseParen)
               importNode.CloseParen.SetValue(string.Empty, -1, -1);
            }

            // We only allow "import" statements at the beginning of files,
            // so if any actual code started (anything that is not an import
            // statement), we will mark this import statement as invalid.
            //
            if (false != codeSegmentStarted)
            {
               if (null != importNode.KwImport)
               importNode.KwImport.SetValue(string.Empty, -1, -1);
            }

            string ModuleName = null;
            if (importNode.Path != null && importNode.Path.value != null && (ModuleName = GetImportedModuleFullPath(importNode.Path.value)) != null && Path.GetExtension(ModuleName) == ".ds")
            {
               if (GlobalModuleTable == null)
               {
               GlobalModuleTable = new Dictionary<string, DesignScript.Parser.Associative.ImportNode>();
               if (core.Options.RootModulePathName != null)
                   GlobalModuleTable[core.Options.RootModulePathName] = null;
               }

               if (GlobalModuleTable.ContainsKey(ModuleName))
               {
               importNode.CodeNode = null;
               importNode.HasBeenImported = true;
               }
               else
               {

               GlobalModuleTable[ModuleName] = importNode;

               string curDirectory = Directory.GetCurrentDirectory();
               Directory.SetCurrentDirectory(Path.GetDirectoryName(ModuleName));

               DesignScript.Parser.Scanner scanner = new DesignScript.Parser.Scanner(ModuleName);
               DesignScript.Parser.Parser parser = new DesignScript.Parser.Parser(scanner, core);
               parser.GlobalModuleTable = GlobalModuleTable;

               parser.Parse();
               Directory.SetCurrentDirectory(curDirectory);

               //if (parseErrors.ToString() != String.Empty)
                   //core.BuildStatus.LogSyntaxError(parseErrors.ToString());
               //core.BuildStatus.errorCount += parser.errors.count;

               importNode.CodeNode = parser.root as DesignScript.Parser.Associative.CodeBlockNode;
               }
            }

            node = importNode;
        }
Пример #27
0
 void Assoc_FunctionCall(out Node node)
 {
     Assoc_Ident(out node);
     DesignScript.Parser.Associative.FunctionCallNode f = new DesignScript.Parser.Associative.FunctionCallNode(); f.Line = node.Line; f.Col = node.Col;
     Assoc_Arguments(ref f);
     f.Function = node;
     node = f;
 }
Пример #28
0
 void Assoc_ArithmeticExpression(out Node node)
 {
     Assoc_Term(out node);
     while (la.kind == 12 || la.kind == 57) {
     DesignScript.Parser.Associative.BinaryExpressionNode binaryNode = new DesignScript.Parser.Associative.BinaryExpressionNode();
     DesignScript.Parser.Associative.IDEHelpNode IDEop = binaryNode.op;
     Assoc_AddOp(ref IDEop);
     binaryNode.op = IDEop; binaryNode.LeftNode = node; node = null;
     Assoc_Term(out node);
     binaryNode.RightNode = node;
     node = binaryNode;
     }
 }
Пример #29
0
 void Assoc_FunctionParameterDecl(out Node node)
 {
     DesignScript.Parser.Associative.VarDeclNode varDeclNode = new DesignScript.Parser.Associative.VarDeclNode();
     Expect(1);
     varDeclNode.Line = t.line; varDeclNode.Col = t.col; varDeclNode.name.SetValue(t.val, t.line, t.col);
     if (t.kind == _ident) varDeclNode.name.SetValue(t.val, t.line, t.col);
     if (la.kind == 54) {
     DesignScript.Parser.Associative.TypeNode IDEType = new DesignScript.Parser.Associative.TypeNode();
     Assoc_TypeRestriction(out IDEType);
     varDeclNode.IDEArgumentType = IDEType;
     }
     if (la.kind == 53) {
     Get();
     if (t.val == "=") varDeclNode.equal.SetValue(t.val, t.line, t.col);
     Node rhsNode = null;
     Assoc_Expression(out rhsNode);
     varDeclNode.NameNode = rhsNode;
     }
     node = varDeclNode;
 }
Пример #30
0
        void Imperative_identifierList(out Node node)
        {
            node = null;

            Imperative_NameReference(out node);
            while (la.kind == 6) {
            Get();
            Node rnode = null;
            DesignScript.Parser.Imperative.IDEHelpNode dotPos = new DesignScript.Parser.Imperative.IDEHelpNode() { Col = t.col, Line = t.line, Value = t.val, Type = DesignScript.Parser.Imperative.IDEHelpNode.HelpNodeType.PunctuationNode };
            Imperative_NameReference(out rnode);
            DesignScript.Parser.Imperative.IdentifierListNode bnode = new DesignScript.Parser.Imperative.IdentifierListNode();
                                            List<DesignScript.Parser.Imperative.IDEHelpNode> dotPosList = new List<DesignScript.Parser.Imperative.IDEHelpNode>();
            dotPosList.Add(dotPos);
            bnode.LeftNode = node;
            bnode.Optr = Operator.dot;
            bnode.RightNode = rnode;
            bnode.Col = node.Col;
            bnode.Line = node.Line;
                                            bnode.DotPosList = dotPosList;
            node = bnode;

            }
        }