Exemplo n.º 1
0
 private void ExpandIdentifier(Node node)
 {
     if (node.Children.Count == 1 && node.Children[0].TokenType == TokenType.Identifier)
     {
         //identifier -> identifier != null ? attrib
         node.AddChild(TokenType.NotEqualTo);
         Node values = node.AddChild(TokenType.Values);
         values.AddChild(TokenType.Null);
         node.AddChild(TokenType.Question);
         Node expressions = node.AddChild(TokenType.Expressions);
         Node expression = expressions.AddChild(TokenType.Expression);
         expression.AddChild(TokenType.Attrib, node.Children[0].Text);
     }
 }
Exemplo n.º 2
0
        private void ExpandIdentifierEqualToValue(Node node)
        {
            if (node.Children.Count == 3
                && node.Children[0].TokenType == TokenType.Identifier
                && (node.Children[1].TokenType == TokenType.EqualTo || node.Children[1].TokenType == TokenType.NotEqualTo)
                && node.Children[2].TokenType == TokenType.Values)
            {
                //identifier=text -> identifier=text?{identifier}
                node.AddChild(TokenType.Question);

                Node expressions = node.AddChild(TokenType.Expressions);
                Node expression = expressions.AddChild(TokenType.Expression);
                expression.AddChild(TokenType.Attrib, node.Children[0].Text);
            }
        }
Exemplo n.º 3
0
        private Node ConsumeAs(Node node, TokenType expectedTokenType, TokenType asTokenType)
        {
            if (IsTokenType(expectedTokenType))
            {
                var ret = node.AddChild(asTokenType, _currentToken.Text);

                Next();

                return ret;
            }

            throw new Exception("Expected " + expectedTokenType);
        }
Exemplo n.º 4
0
        private Node ConsumeAs(Node node, TokenType tokenType)
        {
            var ret = node.AddChild(tokenType, _currentToken.Text);

            Next();

            return ret;
        }
Exemplo n.º 5
0
 private Node Add(Node parent, TokenType tokenType, string text = "")
 {
     return parent.AddChild(tokenType, text);
 }