Exemplo n.º 1
0
        private void Resolve厳密等価演算子(ScriptAnalyser sa2)
        {
            ScriptAnalyser.Token[] tokens = sa2.NBTokens;

            for (int index = 0; index < tokens.Length; index++)
            {
                ScriptAnalyser.Token token = tokens[index];

                if (token.Kind == ScriptAnalyser.Token.Kind_e.SYMBOL && token.Pattern == "==")
                {
                    if (
                        index + 1 < tokens.Length &&
                        tokens[index + 1].Kind == ScriptAnalyser.Token.Kind_e.TOKEN &&
                        tokens[index + 1].Pattern == "false"
                        )
                    {
                        token.Pattern             = "!==";
                        tokens[index + 1].Pattern = "true";
                    }
                    else
                    {
                        token.Pattern = "===";
                    }
                }
                else if (token.Kind == ScriptAnalyser.Token.Kind_e.SYMBOL && token.Pattern == "!=")
                {
                    token.Pattern = "!==";
                }
            }
        }
        private void CollectGlobalIdentifier(ScriptAnalyser sa)
        {
            ScriptAnalyser.Token[] tokens = sa.NBTokens;

            for (int index = 0; index < tokens.Length; index++)
            {
                ScriptAnalyser.Token token = tokens[index];

                if (tokens[index].Kind == ScriptAnalyser.Token.Kind_e.TOKEN &&
                    (tokens[index].Pattern == "function" || tokens[index].Pattern == "var") && index + 1 < tokens.Length &&
                    IsGlobalIdentifier(tokens[index + 1].Pattern))
                {
                    this.Identifiers.Add(tokens[index + 1].Pattern);
                }
            }
        }