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); } }
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); } }
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); }
private Node ConsumeAs(Node node, TokenType tokenType) { var ret = node.AddChild(tokenType, _currentToken.Text); Next(); return ret; }
private Node Add(Node parent, TokenType tokenType, string text = "") { return parent.AddChild(tokenType, text); }