コード例 #1
0
 public JSCNCommand_FunctionCall(JSCNCommand aBaseCommand, List <JSCNCommand> aParameterCommands)
 {
     parameterCommands = aParameterCommands;
     baseCommand       = aBaseCommand;
 }
コード例 #2
0
 public JSCNCommand_GetProperty(JSCNCommand aBaseCommand, string aKey)
 {
     key         = aKey;
     baseCommand = aBaseCommand;
 }
コード例 #3
0
 public JSCNCommand_ArrayIndex(JSCNCommand aBaseCommand, JSCNCommand aIndexCommand)
 {
     indexCommand = aIndexCommand;
     baseCommand  = aBaseCommand;
 }
コード例 #4
0
        public static JSCNCommand parseOperator(JSCNCommand lhs, string text, ref int idx)
        {
            if (text.Length <= idx)
            {
                return(lhs);
            }

            if (text[idx] == '.')
            {
                idx++;
                String propertyName = parseCommandWord(text, ref idx);
                if (propertyName != null)
                {
                    return(new JSCNCommand_GetProperty(lhs, propertyName));
                }
                else
                {
                    ReportError(text, idx, "Expected: a word after '.' operator.");
                }
            }
            else if (text[idx] == '[')
            {
                idx++;
                JSCNCommand indexValue = parseCommand(text, ref idx);

                if (text.Length <= idx)
                {
                    ReportError(text, idx, "Expected: ], got: end of text");
                }
                else if (text[idx] != ']')
                {
                    ReportError(text, idx, "Expected: ], got: " + text[idx]);
                }

                idx++;
                return(new JSCNCommand_ArrayIndex(lhs, indexValue));
            }
            else if (text[idx] == '(')
            {
                idx++;
                List <JSCNCommand> parameters = new List <JSCNCommand>();

                while (true)
                {
                    SkipWhitespace(text, ref idx);
                    if (text.Length <= idx)
                    {
                        ReportError(text, idx, "Expected: ')', got: end of text");
                        break;
                    }
                    else if (text[idx] == ',')
                    {
                        if (parameters.Count == 0)
                        {
                            ReportError(text, idx, "Expected: parameter, got: ','");
                            break;
                        }
                    }
                    else if (text[idx] == ')')
                    {
                        break;
                    }

                    parameters.Add(parseCommand(text, ref idx));
                    SkipWhitespace(text, ref idx);
                }

                if (text.Length <= idx || text[idx] != ')')
                {
                    ReportError(text, idx, "Expected: ')', got: '" + text[idx] + "'");
                }

                idx++;
                return(new JSCNCommand_FunctionCall(lhs, parameters));
            }

            return(lhs);
        }