示例#1
0
        // Token: 0x06000554 RID: 1364 RVA: 0x00010FC8 File Offset: 0x0000F1C8
        public AScannerError GetFloat(bool newLines = true)
        {
            this.parsedFloat = 0f;
            if (this.IsAtEndOfScript)
            {
                return(AScannerError.UnexpectedEOF);
            }
            if (!this.SkipWhitespace(newLines))
            {
                return(AScannerError.UnexpectedEOF);
            }
            StringBuilder stringBuilder = new StringBuilder();

            while (!this.IsAtEndOfScript)
            {
                char c = this.ReadChar();
                if (!AScanner.IsFloat(c))
                {
                    break;
                }
                stringBuilder.Append(c);
            }
            if (stringBuilder.Length == 0)
            {
                return(AScannerError.NothingWasThere);
            }
            this.StepBack(1);
            if (float.TryParse(stringBuilder.ToString(), NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint, NumberFormatInfo.InvariantInfo, out this.parsedFloat))
            {
                return(AScannerError.None);
            }
            return(AScannerError.IncorrectNumberFormat);
        }
 // Token: 0x0600057F RID: 1407 RVA: 0x00011704 File Offset: 0x0000F904
 public AScannerScriptException(AScanner scanner, string format, params object[] args) : base(string.Format("Script \"{0}\" on line {1}, pos {2}:\n{3}", new object[]
 {
     scanner.ScriptName,
     scanner.CurrentLine,
     scanner.CurrentLinePosition,
     string.Format(format, args)
 }))
 {
 }
示例#3
0
        // Token: 0x0600055D RID: 1373 RVA: 0x00011214 File Offset: 0x0000F414
        public AScannerError GetToken(bool newLines, AScannerTokenScanModes scanmode)
        {
            this.parsedToken = null;
            this.TokenType   = AScannerTokenType.Text;
            if (this.IsAtEndOfScript)
            {
                return(AScannerError.UnexpectedEOF);
            }
            if (!this.SkipWhitespace(newLines))
            {
                return(AScannerError.UnexpectedEOF);
            }
            StringBuilder stringBuilder = new StringBuilder();
            char          c             = this.ReadChar();

            stringBuilder.Append(c);
            if (!scanmode.HasFlag(AScannerTokenScanModes.SymbolsAsText) && AScanner.IsTokenSymbol(c))
            {
                this.TokenType   = AScannerTokenType.Symbol;
                this.parsedToken = stringBuilder.ToString();
                return(AScannerError.None);
            }
            if (!scanmode.HasFlag(AScannerTokenScanModes.OperatorsAsText) && AScanner.IsTokenOperator(c))
            {
                this.TokenType = AScannerTokenType.Operator;
                while (!this.IsAtEndOfScript)
                {
                    c = this.ReadChar();
                    if (!AScanner.IsTokenOperator(c))
                    {
                        this.StepBack(1);
                        break;
                    }
                    stringBuilder.Append(c);
                }
            }
            else
            {
                while (!this.IsAtEndOfScript)
                {
                    c = this.ReadChar();
                    if ((!scanmode.HasFlag(AScannerTokenScanModes.SymbolsAsText) && AScanner.IsTokenSymbol(c)) || (!scanmode.HasFlag(AScannerTokenScanModes.OperatorsAsText) && AScanner.IsTokenOperator(c)) || c == '"' || AScanner.IsWhitespace(c) || AScanner.IsNewline(c))
                    {
                        this.StepBack(1);
                        break;
                    }
                    stringBuilder.Append(c);
                }
            }
            if (stringBuilder.Length == 0)
            {
                return(AScannerError.NothingWasThere);
            }
            this.parsedToken = stringBuilder.ToString();
            return(AScannerError.None);
        }
示例#4
0
        // Token: 0x0600056E RID: 1390 RVA: 0x000114E0 File Offset: 0x0000F6E0
        public bool SkipWhitespace(bool skipNewlines = false)
        {
            if (this.IsAtEndOfScript)
            {
                return(false);
            }
            char c = this.ReadChar();

            while (AScanner.IsWhitespace(c) || (skipNewlines && AScanner.IsNewline(c)) || c == '/')
            {
                if (c == '/' && !this.IsAtEndOfScript)
                {
                    c = this.ReadChar();
                    if (c == '/')
                    {
                        while (!this.IsAtEndOfScript)
                        {
                            if (AScanner.IsNewline(c))
                            {
                                break;
                            }
                            c = this.ReadChar();
                        }
                    }
                    else
                    {
                        if (c != '*')
                        {
                            this.StepBack(1);
                            break;
                        }
                        while (this.Script.Position < this.Script.Length - 1L)
                        {
                            char c2 = this.ReadChar();
                            char c3 = this.ReadChar();
                            if (c2 == '*' && c3 == '/')
                            {
                                break;
                            }
                            this.StepBack(1);
                        }
                    }
                }
                if (this.IsAtEndOfScript)
                {
                    return(false);
                }
                c = this.ReadChar();
            }
            this.StepBack(1);
            return(true);
        }
示例#5
0
        // Token: 0x06000551 RID: 1361 RVA: 0x00010E88 File Offset: 0x0000F088
        public AScannerError GetInteger(bool newLines = true)
        {
            this.parsedInteger = 0;
            if (this.IsAtEndOfScript)
            {
                return(AScannerError.UnexpectedEOF);
            }
            if (!this.SkipWhitespace(newLines))
            {
                return(AScannerError.UnexpectedEOF);
            }
            StringBuilder stringBuilder = new StringBuilder();

            while (!this.IsAtEndOfScript)
            {
                char c = this.ReadChar();
                if (!AScanner.IsNumber(c))
                {
                    break;
                }
                stringBuilder.Append(c);
            }
            if (stringBuilder.Length == 0)
            {
                return(AScannerError.NothingWasThere);
            }
            this.StepBack(1);
            string text = stringBuilder.ToString();

            if (text.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
            {
                if (int.TryParse(text.Substring(2), NumberStyles.AllowLeadingSign | NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out this.parsedInteger))
                {
                    return(AScannerError.None);
                }
                return(AScannerError.IncorrectNumberFormat);
            }
            else
            {
                if (int.TryParse(text, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out this.parsedInteger))
                {
                    return(AScannerError.None);
                }
                return(AScannerError.IncorrectNumberFormat);
            }
        }
示例#6
0
        // Token: 0x06000557 RID: 1367 RVA: 0x000110DC File Offset: 0x0000F2DC
        public AScannerError GetString(bool newLines = true)
        {
            this.parsedString = null;
            if (this.IsAtEndOfScript)
            {
                return(AScannerError.UnexpectedEOF);
            }
            if (!this.SkipWhitespace(newLines))
            {
                return(AScannerError.UnexpectedEOF);
            }
            if (this.ReadChar() != '"')
            {
                this.StepBack(1);
                return(AScannerError.MissingQuote);
            }
            StringBuilder stringBuilder = new StringBuilder();

            for (;;)
            {
                char c = this.ReadChar();
                if (c == '"' && stringBuilder.Length > 0 && stringBuilder[stringBuilder.Length - 1] != '\\')
                {
                    goto IL_7F;
                }
                if (AScanner.IsNewline(c))
                {
                    break;
                }
                stringBuilder.Append(c);
                if (this.IsAtEndOfScript)
                {
                    return(AScannerError.UnexpectedEOF);
                }
            }
            this.StepBack(1);
            return(AScannerError.MissingQuote);

IL_7F:
            this.parsedString = stringBuilder.ToString();
            return(AScannerError.None);
        }
示例#7
0
 // Token: 0x0600057C RID: 1404 RVA: 0x000116D8 File Offset: 0x0000F8D8
 protected static bool IsTokenOperator(string str)
 {
     return(str != null && str.Length != 0 && AScanner.IsTokenOperator(str[0]));
 }
示例#8
0
 // Token: 0x06000578 RID: 1400 RVA: 0x0001167C File Offset: 0x0000F87C
 protected static bool IsFloat(string str)
 {
     return(str != null && str.Length != 0 && AScanner.IsFloat(str[0]));
 }