public ScriptVariableDefinition(ScriptVariableType varType, ScriptIdentifierToken name)
 {
     VarType = varType;
     Name    = name;
 }
Example #2
0
        protected virtual int TryParseIdentifier(out ScriptToken codeObj)
        {
            int           state = 0, pos = this.Position, len = this.Length;
            char          c;
            StringBuilder id           = null;
            bool          checkKeyword = true;

            while (pos < len && state < 3)
            {
                c = this.ScriptText[pos++];
                switch (state)
                {
                case 0:
                    if (c == '@')
                    {
                        checkKeyword = false;
                        state        = 1;
                        break;
                    }
                    goto case 1;

                case 1:
                    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_')
                    {
                        id = new StringBuilder();
                        id.Append(c);
                        state = 2;
                    }
                    else
                    {
                        state = 3;
                    }
                    break;

                case 2:
                    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')
                    {
                        id.Append(c);
                    }
                    else
                    {
                        pos--;
                        state = 3;
                    }
                    break;
                }
            }

            if (id != null)
            {
                string strId = id.ToString();
                if (checkKeyword)
                {
                    foreach (string keyword in this.Keywords)
                    {
                        if (strId.Equals(keyword))
                        {
                            codeObj = new ScriptKeywordToken(strId, Line, Symbol);
                            return(pos - this.Position);
                        }
                    }
                }
                codeObj = new ScriptIdentifierToken(strId, Line, Symbol);
                return(pos - this.Position);
            }

            codeObj = null;
            return(0);
        }