@Test public void testNameLiteral() { CommonParser parser = CommonParser.instance(); Rule rule = parser.input(parser.NameLiteral()); assertTrue(matches("a", rule)); assertTrue(matches("has/", rule)); assertTrue(matches("~startTilde", rule)); assertTrue(matches(":startColon", rule)); assertTrue(matches("\"a\"", rule)); assertTrue(matches("\" \\\" \"", rule)); assertTrue(matches("\" \\t,\\&()[]@\"", rule)); assertFalse(matches("has space", rule)); assertFalse(matches("has\\t", rule)); assertFalse(matches("has,", rule)); assertFalse(matches("has\\", rule)); assertFalse(matches("has&", rule)); assertFalse(matches("has(", rule)); assertFalse(matches("has)", rule)); assertFalse(matches("has[", rule)); assertFalse(matches("has]", rule)); assertFalse(matches("1startDigit", rule)); assertFalse(matches("/startSlash", rule)); assertFalse(matches("@startAt", rule)); assertFalse(matches("", rule)); assertFalse(matches("\"", rule)); assertFalse(matches("\"\"", rule)); }
public Rule NameLiteral() { return FirstOf( Sequence( TestNot(EscapeChar()), TestNot(Digit()), TestNot(Slash()), OneOrMore(AsciiButNot(SPECIAL_CHARS)), push(new StringAstNode(match()))), Sequence( EscapeChar(), OneOrMore(FirstOf(EscapedQuote(), AsciiButNot("\""))), push(new StringAstNode(match())), EscapeChar())); }
CommonParser extends BaseParser<AstNode> { public Rule NameLiteral() { return FirstOf( Sequence( TestNot(EscapeChar()), TestNot(Digit()), TestNot(Slash()), OneOrMore(AsciiButNot(SPECIAL_CHARS)), push(new StringAstNode(match()))), Sequence( EscapeChar(), OneOrMore(FirstOf(EscapedQuote(), AsciiButNot("\""))), push(new StringAstNode(match())), EscapeChar())); } }
CommonParser extends BaseParser<AstNode> { public Rule NameLiteral() { return FirstOf( Sequence( TestNot(EscapeChar()), TestNot(Digit()), TestNot(Slash()), OneOrMore(AsciiButNot(SPECIAL_CHARS)), push(new StringAstNode(match()))), Sequence( EscapeChar(), OneOrMore(FirstOf(EscapedQuote(), AsciiButNot("\""))), push(new StringAstNode(match())), EscapeChar())); }  }
CommonParser extends BaseParser<AstNode> { public Rule NameLiteral() { return FirstOf( Sequence( TestNot(EscapeChar()), TestNot(Digit()), TestNot(Slash()), OneOrMore(AsciiButNot(SPECIAL_CHARS)), push(new StringAstNode(match()))), Sequence( EscapeChar(), OneOrMore(FirstOf(EscapedQuote(), AsciiButNot("\""))), push(new StringAstNode(match())), EscapeChar())); }  Rule input(Rule expression); Rule AlphabetChar(); @Anchor(Type.IGNORE) Rule AsciiButNot(String characters); Rule At(); Rule Dash(); Rule Digit(); Rule Dot(); Rule EnumValue(); Rule EscapeChar(); @Anchor(Type.IGNORE) Rule EscapedSlash(); @Anchor(Type.IGNORE) Rule EscapedQuote(); Rule IpAddressUnchecked(); Rule IpPrefixUnchecked(); Rule NameLiteral(); Rule Number(); @Anchor(OPERATOR_END) Rule CloseBrackets(); @Anchor(OPERATOR_END) Rule CloseParens(); Rule Regex(); Rule RegexDeprecated(); Rule Slash(); Rule Tilde(); Rule Underscore(); @Anchor(Type.WHITESPACE) Rule WhiteSpace(); }
CommonParser extends BaseParser<AstNode> { public Rule NameLiteral() { return FirstOf( Sequence( TestNot(EscapeChar()), TestNot(Digit()), TestNot(Slash()), OneOrMore(AsciiButNot(SPECIAL_CHARS)), push(new StringAstNode(match()))), Sequence( EscapeChar(), OneOrMore(FirstOf(EscapedQuote(), AsciiButNot("\""))), push(new StringAstNode(match())), EscapeChar())); }  Rule input(Rule expression); Rule AlphabetChar(); @Anchor(Type.IGNORE) Rule AsciiButNot(String characters); Rule At(); Rule Dash(); Rule Digit(); Rule Dot(); Rule EnumValue(); Rule EscapeChar(); @Anchor(Type.IGNORE) Rule EscapedSlash(); @Anchor(Type.IGNORE) Rule EscapedQuote(); Rule IpAddressUnchecked(); Rule IpPrefixUnchecked(); Rule NameLiteral(); Rule Number(); @Anchor(OPERATOR_END) Rule CloseBrackets(); @Anchor(OPERATOR_END) Rule CloseParens(); Rule Regex(); Rule RegexDeprecated(); Rule Slash(); Rule Tilde(); Rule Underscore(); @Anchor(Type.WHITESPACE) Rule WhiteSpace(); static Set<String> namedApplications; }