TPG error when using 't' as the first letter of a token

Andrew James drew at
Thu Nov 18 23:43:17 CET 2004

Thanks for your detailed response. I've read through the PyParsing site
and I'm considering using it for further development of my project -
wish I'd found it before!

I noted your comments about my last test case; the syntax of the
language I'm implementing is closely related to XPath and the [] at the
end of the query are intended to contain metadata criteria. I have since
revised my parsing rules (see below) and they now parse both the
original test queries and arbitrarily complex boolean expressions.

I'm just about to post a new message with a description of what the
language is aimed at doing and asking for any improvements - I would
value your opinion if you have the time.

    # Tokens
    separator space '\s+';
    token Num '\d+(.\d+)?';
    token Ident '[a-zA-Z]\w*';
    token CharList '\'.*\'';
    token CatUnOp '~';
    token CatOp '[/\^]';
    token MetaOp '[=\+\-!]';
    token Date '\d\d-\d\d-\d\d\d\d';
    token FileID '(\w+\.\w+)';
    token EmptyLine '^$';
    # Rules
    START -> CatExpr ('\[' MetaExpr '\]')?
    | FileID
    | EmptyLine
    CatExpr -> CatUnOp CatName
    | CatName (CatOp CatExpr)*
    CatName -> Ident
    | '\(' CatExpr '\)'
    MetaExpr -> MetaCrit (',' MetaCrit)*
    MetaCrit -> Ident MetaOp Value
    Value -> CharList | Num | Date

parseTests = (


More information about the Python-list mailing list