public bool Parse(TokensReader expression, bool expression_end) { body = null; TokenType token = expression.tokens.Pop(); if (token == TokenType.IF) { statement = PartTemplate.ParseStatement(ref expression); if (expression_end) { body = expression; } return(true); } else { return(false); } }
public bool Parse(TokensReader expression, bool expression_end) { field = null; local = null; valuetype = null; if (expression.tokens.Pop() == TokenType.LITERAL && expression_end) { expression.tokens.Insert(0, TokenType.LITERAL); TokensReader backup = new TokensReader(); backup.Add(expression); local = PartTemplate.ParseLocal(ref expression); if (local == null) // is field { expression = backup; field = PartTemplate.ParseField(ref expression); } if (expression.tokens.Pop() == TokenType.OPERATOR && expression.operators.Pop() == OperatorType.ASSIGN) { valuetype = PartTemplate.ParseValue(ref expression); if (expression.tokens.Count == 0) { return(true); } else { return(false); } } else { return(false); } } else { return(false); } }
public bool Parse(TokensReader expression, bool expression_end) { if (!expression_end) { return(false); } LaterCalls.Seek(); paramTypes = new List <Type>(); methname = ""; typename = ""; TokenType token = expression.tokens.Pop(); if (token == TokenType.LITERAL) { bool mustLiteral = true; StringBuilder parentName = new StringBuilder(); string lastLiteral = ""; while (token == TokenType.LITERAL || token == TokenType.SEPARATOR) { if (mustLiteral && token == TokenType.LITERAL) { lastLiteral = expression.string_values.Pop(); mustLiteral = false; } else if (!mustLiteral && token == TokenType.SEPARATOR) { mustLiteral = true; if (expression.bool_values.Pop()) { parentName.Append(lastLiteral + "."); } else { break; } } else { break; } token = expression.tokens.Pop(); } if (mustLiteral) { return(false); } else { if (parentName.Length == 0) { parentName.Append(lastLiteral); } else { parentName.Length--; // delete last character - '.' } typename = parentName.ToString(); methname = lastLiteral; if (token == TokenType.STATEMENT && expression.bool_values.Pop()) { if (expression.tokens[0] == TokenType.STATEMENT && !expression.bool_values[0]) { if (expression.tokens.Count == 1) { return(true); } else { return(false); } } else { parse_param: Type paramType = PartTemplate.ParseValue(ref expression); if (paramType == null) { return(false); } else { paramTypes.Add(paramType); token = expression.tokens.Pop(); if (token == TokenType.STATEMENT) { if (!expression.bool_values.Pop()) { if (expression.tokens.Count == 0) { return(true); } else { return(false); } } else { expression.bool_values.Insert(0, true); } } else if (token == TokenType.SEPARATOR && !expression.bool_values.Pop()) { goto parse_param; } else { return(false); } } return(false); } } else { return(false); } } } else { return(false); } }