Example #1
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;
 }
Example #2
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;
 }
Example #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;
        }
Example #4
0
 void Assoc_TypeRestriction(out DesignScript.Parser.Associative.TypeNode IDEType)
 {
     IDEType = new DesignScript.Parser.Associative.TypeNode();
     ExpectWeak(54, 11);
     if (t.val == ":") IDEType.colon.SetValue(t.val, t.line, t.col);
     if (StartOf(12)) {
     if (la.kind == 37) {
         Get();
     } else if (la.kind == 38) {
         Get();
     } else if (la.kind == 39) {
         Get();
     } else {
         Get();
     }
     IDEType.BuildInTypeSetValue(t.val, t.line, t.col);
     } else if (la.kind == 1) {
     Get();
     IDEType.UserDefinedTypeSetValue(t.val, t.line, t.col);
     } else SynErr(90);
     while (la.kind == 7) {
     string openBracket = null; string closeBracket = null;
     if (la.val == "[")  openBracket = la.val; int bracket_line = la.line; int bracket_col = la.col;
     Get();
     if (la.val == "]") closeBracket = la.val;
     Expect(8);
     if (openBracket != null && closeBracket != null) IDEType.AddBracket(openBracket, bracket_line, bracket_col, closeBracket, t.line, t.col);
     if (la.kind == 21) {
         Get();
         IDEType.op.SetValue(t.val, t.line, t.col);
         string multiDimOpenBracket = null; string multiDimCloseBracket = null;
         if (la.val == "[")  multiDimOpenBracket = la.val; int bracket2_line = la.line; int bracket2_col = la.col;
         Expect(7);
         if (la.val == "]")  multiDimCloseBracket = la.val;
         Expect(8);
         if (multiDimOpenBracket != null && multiDimCloseBracket != null)
         IDEType.AddMultiDimNodes(multiDimOpenBracket, bracket2_line, bracket2_col, multiDimCloseBracket, t.line, t.col);
     }
     }
 }