コード例 #1
0
 public FunctionSyntaxElement(LexicalElement lexAtStart, IList <IdentifierSyntaxElement> parameters, SyntaxElement body, bool isParams)
     : base(lexAtStart)
 {
     this.Parameters = parameters;
     this.Body       = body;
     this.IsParams   = isParams;
 }
コード例 #2
0
 public FunctionVariable(IList <Parse.IdentifierSyntaxElement> parameters, Parse.SyntaxElement body, bool isParams)
     : base(ScriptVariableType.Function)
 {
     this.Parameters = parameters;
     this.Body       = body;
     this.IsParams   = isParams;
 }
コード例 #3
0
 public DoWhileSyntaxElement(LexicalElement lexAtStart, ExpressionSyntaxElement condition, SyntaxElement statement, bool @do)
     : base(lexAtStart)
 {
     this.Condition = condition;
     this.Statement = statement;
     this.Do        = @do;
 }
コード例 #4
0
 public IfSyntaxElement(LexicalElement lexAtStart, ExpressionSyntaxElement condition, SyntaxElement then, SyntaxElement @else)
     : base(lexAtStart)
 {
     this.Condition = condition;
     this.Then      = then;
     this.Else      = @else;
 }
コード例 #5
0
 public ForeachSyntaxElement(LexicalElement lexAtStart, string identifier, bool declare, ExpressionSyntaxElement enumerator, SyntaxElement statement)
     : base(lexAtStart)
 {
     this.Identifier = identifier;
     this.Declare    = declare;
     this.Enumerator = enumerator;
     this.Statement  = statement;
 }
コード例 #6
0
 public ForSyntaxElement(LexicalElement lexAtStart, ExpressionSyntaxElement initialize, ExpressionSyntaxElement condition, ExpressionSyntaxElement @continue, SyntaxElement statement)
     : base(lexAtStart)
 {
     this.Initialize = initialize;
     this.Condition  = condition;
     this.Continue   = @continue;
     this.Statement  = statement;
 }
コード例 #7
0
        protected override ExpressionSyntaxElement ReturnFunc(LexicalElement func, LexicalElement openPar, Optional <FixedList <Optional <LexicalElement>, Optional <LexicalElement>, IdentifierSyntaxElement, FixedList <LexicalElement, Optional <LexicalElement>, Optional <LexicalElement>, IdentifierSyntaxElement>[]> > optOf_OptOfParams_And_OptOfVar_AndIdentifierAnd_RepeatOfCommaAnd_OptOfParams_And_OptOfVar_AndIdentifier, LexicalElement closePar, SyntaxElement block)
        {
            List <IdentifierSyntaxElement> @params = new List <IdentifierSyntaxElement>();
            bool isParam = false;

            if (optOf_OptOfParams_And_OptOfVar_AndIdentifierAnd_RepeatOfCommaAnd_OptOfParams_And_OptOfVar_AndIdentifier.HasValue)
            {
                var tmp        = optOf_OptOfParams_And_OptOfVar_AndIdentifierAnd_RepeatOfCommaAnd_OptOfParams_And_OptOfVar_AndIdentifier.Value;
                var param      = tmp.Element1;
                var var        = tmp.Element2;
                var identifier = tmp.Element3;
                var repeat     = tmp.Element4;
                if (optOf_OptOfParams_And_OptOfVar_AndIdentifierAnd_RepeatOfCommaAnd_OptOfParams_And_OptOfVar_AndIdentifier.Value.Element1.HasValue)
                {
                    isParam = true;
                }
                @params.Add(identifier);
                foreach (var successor in repeat)
                {
                    var comma       = successor.Element1;
                    var param2      = successor.Element2;
                    var var2        = successor.Element3;
                    var identifier2 = successor.Element4;
                    @params.Add(identifier2);
                }
            }
            return(new FunctionSyntaxElement(func, @params, block, isParam));
        }
コード例 #8
0
 protected override ForeachSyntaxElement ReturnForeach(LexicalElement @foreach, LexicalElement openPar, Optional <LexicalElement> optOfVar, IdentifierSyntaxElement identifier, LexicalElement @in, ExpressionSyntaxElement expression, LexicalElement closePar, SyntaxElement statement)
 {
     return(new ForeachSyntaxElement(@foreach, identifier.Identifier, optOfVar.HasValue, expression, statement));
 }
コード例 #9
0
 /// <summary>
 /// if = 'if', '(', expression, ')', statement, ['else', statement] ;
 /// </summary>
 /// <param name="@if">'if'</param>
 /// <param name="openPar">'('</param>
 /// <param name="expression">expression</param>
 /// <param name="closePar">')'</param>
 /// <param name="statement">statement</param>
 /// <param name="else_Statement_opt">['else', statement]</param>
 protected override IfSyntaxElement ReturnIf(LexicalElement @if, LexicalElement openPar, ExpressionSyntaxElement expression, LexicalElement closePar, SyntaxElement statement, Optional <FixedList <LexicalElement, SyntaxElement> > else_Statement_opt)
 {
     if (else_Statement_opt.HasValue)
     {
         return(new IfSyntaxElement(@if, expression, statement, else_Statement_opt.Value.Element2));
     }
     return(new IfSyntaxElement(@if, expression, statement));
 }
コード例 #10
0
 /// <summary>
 /// do = 'do', statement, 'while', '(', expression, ')', ';' ;
 /// </summary>
 /// <param name="@do">'do'</param>
 /// <param name="statement">statement</param>
 /// <param name="@while">'while'</param>
 /// <param name="openPar">'('</param>
 /// <param name="expression">expression</param>
 /// <param name="closePar">')'</param>
 /// <param name="semicolon">';'</param>
 protected override DoWhileSyntaxElement ReturnDo(LexicalElement @do, SyntaxElement statement, LexicalElement @while, LexicalElement openPar, ExpressionSyntaxElement expression, LexicalElement closePar, LexicalElement semicolon)
 {
     return(new DoWhileSyntaxElement(@do, expression, statement, true));
 }
コード例 #11
0
 /// <summary>
 /// while = 'while', '(', expression, ')', statement ;
 /// </summary>
 /// <param name="@while">'while'</param>
 /// <param name="openPar">'('</param>
 /// <param name="expression">expression</param>
 /// <param name="closePar">')'</param>
 /// <param name="statement">statement</param>
 protected override DoWhileSyntaxElement ReturnWhile(LexicalElement @while, LexicalElement openPar, ExpressionSyntaxElement expression, LexicalElement closePar, SyntaxElement statement)
 {
     return(new DoWhileSyntaxElement(@while, expression, statement, false));
 }
コード例 #12
0
        /// <summary>
        /// for = 'for', '(', [expression|declare], ';', [expression], ';', [expression], ')', statement ;
        /// </summary>
        /// <param name="@for">'for'</param>
        /// <param name="openPar">'('</param>
        /// <param name="selection_opt">[expression|declare]</param>
        /// <param name="semicolon_1">';'</param>
        /// <param name="expression_opt_1">[expression]</param>
        /// <param name="semicolon_2">';'</param>
        /// <param name="expression_opt_2">[expression]</param>
        /// <param name="closePar">')'</param>
        /// <param name="statement">statement</param>
        protected override ForSyntaxElement ReturnFor(LexicalElement @for, LexicalElement openPar, Optional <Selection <ExpressionSyntaxElement, MultiDeclareSyntaxElement> > selection_opt, LexicalElement semicolon_1, Optional <ExpressionSyntaxElement> expression_opt_1, LexicalElement semicolon_2, Optional <ExpressionSyntaxElement> expression_opt_2, LexicalElement closePar, SyntaxElement statement)
        {
            ExpressionSyntaxElement init = null;

            if (selection_opt.HasValue)
            {
                if (selection_opt.Value.Element1.HasValue)
                {
                    init = selection_opt.Value.Element1.Value;
                }
                if (selection_opt.Value.Element2.HasValue)
                {
                    init = selection_opt.Value.Element2.Value;
                }
            }
            ExpressionSyntaxElement cond = null;

            if (expression_opt_1.HasValue)
            {
                cond = expression_opt_1.Value;
            }
            ExpressionSyntaxElement cont = null;

            if (expression_opt_2.HasValue)
            {
                cont = expression_opt_2.Value;
            }
            return(new ForSyntaxElement(@for, init, cond, cont, statement));
        }
コード例 #13
0
 protected override SyntaxElement ReturnStatement(SyntaxElement block)
 {
     return(block);
 }
コード例 #14
0
 public ControlSyntaxElement(LexicalElement lexAtStart, SyntaxElement returnValue)
     : base(lexAtStart)
 {
     this.Type        = RunControlType.Return;
     this.ReturnValue = returnValue;
 }
コード例 #15
0
 public IfSyntaxElement(LexicalElement lexAtStart, ExpressionSyntaxElement condition, SyntaxElement then)
     : this(lexAtStart, condition, then, null)
 {
 }