public static EntityReferenceParseResult Parse(string entityRef) { var tokens = RuleLexer.Analyse(entityRef ?? string.Empty); var firstErr = tokens.FirstOrDefault(t => t.TokenType == ApplyIfTokenType.Error); if (firstErr != null) { var lexingError = $@"""{firstErr.Text}"" is not a valid token."; var name = new EntityReferenceParseResult(lexingError); return(name); } var rule = PerformParse(tokens, out var error); if (!string.IsNullOrWhiteSpace(error)) { return(new EntityReferenceParseResult(error)); } return(rule); }
internal static ApplyIfRule Parse(string applyIfSpec) { var tokens = RuleLexer.Analyse(applyIfSpec ?? string.Empty); var firstErr = tokens.FirstOrDefault(t => t.TokenType == ApplyIfTokenType.Error); if (firstErr != null) { var lexingError = $@"""{firstErr.Text}"" is not a valid token."; var name = new ApplyIfRule(new ApplyIfRuleErrorClause($"ApplyIf rule could not be interpreted. (\"{firstErr.Text}\" is not valid.)")); name.FailedParse(lexingError); return(name); } var rule = PerformParse(tokens, out var error); if (!string.IsNullOrWhiteSpace(error)) { rule.FailedParse(error); } return(rule); }