Ejemplo n.º 1
0
 public Tree(LexicalTree_Function function)
 {
     Token    = default(Token);
     Function = function;
     Children = null;
     Type     = 1;
 }
Ejemplo n.º 2
0
        public Tree(ref Token token)
        {
            Token    = token;
            Function = null;
            Children = null;
            if (token.Symbol1 == '@')
            {
                Type = 6;
            }
            else if (token.Type == 2)
            {
                Type = 2;
            }
            else if (token.Type == 1)
            {
                switch (token.Symbol1)
                {
                case '+':
                case '-':
                case '*':
                case '/':
                case '%':
                case '(':
                case ')':
                    if (token.IsDoubleSymbol)
                    {
                        throw new Exception(token.DebugInfo);
                    }
                    Type     = 0;
                    Children = new Tree[2];
                    break;

                case '&':
                    if (token.IsSingleSymbol || token.Symbol2 != '&')
                    {
                        throw new Exception(token.DebugInfo);
                    }
                    Type     = 0;
                    Children = new Tree[2];
                    break;

                case '|':
                    if (token.IsSingleSymbol || token.Symbol2 != '|')
                    {
                        throw new Exception(token.DebugInfo);
                    }
                    Type     = 0;
                    Children = new Tree[2];
                    break;

                case '!':
                case '=':
                    if (token.IsSingleSymbol || token.Symbol2 != '=')
                    {
                        throw new Exception(token.DebugInfo);
                    }
                    Type     = 0;
                    Children = new Tree[2];
                    break;

                case '>':
                case '<':
                    if (token.IsDoubleSymbol && token.Symbol2 != '=')
                    {
                        throw new Exception(token.DebugInfo);
                    }
                    Type     = 0;
                    Children = new Tree[2];
                    break;

                default:
                    throw new Exception();
                }
            }
            else if (ScenarioData2Helper.Identifier.IsMatch(token.Content))
            {
                Type = 3;
            }
            else if (ScenarioData2Helper.Variable.IsMatch(token.Content))
            {
                Type = 4;
            }
            else
            {
                Type = 5;
            }
        }
Ejemplo n.º 3
0
 internal static Tree Convert(LexicalTree_Function tree) => new Tree(tree);