1 classmap XPathClassMap;
2
3 tokens XPathTokens
4 {
5 (OR, "'or'"), (AND, "'and'"), (EQ, "'='"), (NEQ, "'!='"), (LEQ, "'<='"), (GEQ, "'>='"), (LESS, "'<'"), (GREATER, "'>'"), (PLUS, "'+'"), (MINUS, "'-'"), (STAR, "'*"), (DIV, "'div'"), (MOD, "'mod'"),
6 (UNION, "'|'"), (SLASHSLASH, "'//'"), (SLASH, "'/'"), (DOTDOT, "'..'"), (DOT, "'.'"), (COLONCOLON, "'::'"), (COLON, "':'"), (DOLLAR, "'$'"), (COMMA, "','"),
7 (ANCESTOR, "'ancestor'"), (ANCESTOR_OR_SELF, "'ancestor-or-self'"), (ATTRIBUTE, "'attribute'"), (CHILD, "'child'"), (DESCENDANT, "'descendant'"), (DESCENDANT_OR_SELF, "'descendant-or-self'"),
8 (FOLLOWING, "'following'"), (FOLLOWING_SIBLING, "'following-sibling'"), (NAMESPACE, "'namespace'"), (PARENT, "'parent'"), (PRECEDING, "'preceding'"), (PRECEDING_SIBLING, "'preceding-sibling'"),
9 (SELF, "'self'"), (AT, "'@'"), (LBRACKET, "'['"), (RBRACKET, "']'"), (PROCESSING_INSTRUCTION, "'processing-instruction'"), (LPAREN, "'('"), (RPAREN, "')'"), (COMMENT, "'comment'"), (TEXT, "'text'"),
10 (NODE, "'node'"), (DQSTRING, "string"), (SQSTRING, "string"), (NUMBER, "number"), (NAME, "name")
11 }
12
13 keywords XPathKeywords
14 {
15 ("or", OR), ("and", AND), ("div", DIV), ("mod", MOD), ("ancestor", ANCESTOR), ("ancestor-or-self", ANCESTOR_OR_SELF), ("attribute", ATTRIBUTE), ("child", CHILD), ("descendant", DESCENDANT),
16 ("descendant-or-self", DESCENDANT_OR_SELF), ("following", FOLLOWING), ("following-sibling", FOLLOWING_SIBLING), ("namespace", NAMESPACE), ("parent", PARENT), ("preceding", PRECEDING),
17 ("preceding-sibling", PRECEDING_SIBLING), ("self", SELF), ("processing-instruction", PROCESSING_INSTRUCTION), ("comment", COMMENT), ("text", TEXT), ("node", NODE)
18 }
19
20 expressions
21 {
22 ws = "[\n\r\t ]";
23 separators = "{ws}+";
24 dqstring = "\"[^\"]*\"";
25 sqstring = "'[^']*'";
26 digits = "[0-9]+";
27 number = "{digits}(\.{digits}?)?|\.{digits}";
28 namestartchar = "[A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\x2FF\x370-\x37D\x37F-\x1FFF\x200C-\x200D\x2070-\x218F\x2C00-\x2FEF\x3001-\xD7FF\xF900-\xFDCF\xFDF0-\xFFFD\x10000-\xEFFFF]";
29 namechar = "{namestartchar}|[-\.0-9\xB7\x300-\x36F\x203F-\x2040]";
30 name = "{namestartchar}{namechar}*";
31 }
32
33 lexer XPathLexer
34 {
35 "{separators}" {}
36 "{name}" { return NAME; }
37 "{number}" { return NUMBER; }
38 "{dqstring}" { return DQSTRING; }
39 "{sqstring}" { return SQSTRING; }
40 "=" { return EQ; }
41 "!=" { return NEQ; }
42 "<=" { return LEQ; }
43 ">=" { return GEQ; }
44 "<" { return LESS; }
45 ">" { return GREATER; }
46 "\+" { return PLUS; }
47 "-" { return MINUS; }
48 "\*" { return STAR; }
49 "\|" { return UNION; }
50 "//" { return SLASHSLASH; }
51 "/" { return SLASH; }
52 "\.\." { return DOTDOT; }
53 "\." { return DOT; }
54 "::" { return COLONCOLON; }
55 ":" { return COLON; }
56 "$" { return DOLLAR; }
57 "," { return COMMA; }
58 "@" { return AT; }
59 "\[" { return LBRACKET; }
60 "\]" { return RBRACKET; }
61 "\(" { return LPAREN; }
62 "\)" { return RPAREN; }
63 }