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