CRE Parser

This is the parser for CRE in TPE format.

    Assert <- ASSERT '(' Sequence ')'   
    Atom <- 'any' / LITERAL / SINGLE / ZERO  
    BackRef <- 'REF' '(' (DIGIT / IDENTIFIER) ')'   
    Capture <- '{' Sequence ('as' IDENTIFIER)? '}'    

    Char <- CHAR / CHAR_LITERAL / SINGLE

    # Examples:  a  0x00  &201c  &space

    Choice <- 'either' Sequence ('or' Sequence)+    
    Class <- 'chars' '[' ClassItem+ ']'    
    ClassItem <- Char '-' Char / Char / CLUMP / NegatableInClass    
    Definition <- IDENTIFIER '=' Sequence   
    Flags <- 'flags' '(' IDENTIFIER* ')'    
    Group <- '(' Sequence ')'   
    Negatable <- '!'? (Class / Assert / PERL / POSIX / UNICODE)    
    NegatableInClass <- '!'? (PERL / POSIX / UNICODE)
        # Examples:  word  !digit  :alnum  !:space  ::Greek  !::Greek


    Primary <- Atom
             / Negatable
             / IDENTIFIER ! '='
             / Group
             / Capture
             / Choice
             / BackRef

    RepeatRange <- DIGIT? '..' DIGIT?   

    RepeatSpec <- '(' MODIFIER?
                  ( RepeatRange / DIGIT / '?' / '*' / '+' )
                  ')'

    Sequence <- Suffix+   

    SimpleRepeat <- '?' / '*' / '+'
                  / '??' / '**' / '++'

    Start <- Flags? (Sequence / Definition+) !.    
    Suffix <- Primary ( SimpleRepeat / '^' DIGIT / '^' RepeatSpec )?    

Last modified: 2013-01-20 00:37:12 -0800