lex start { token id /[a-zA-Z_][a-zA-Z0-9_]*/ literal '=', '<', '>', '/' ignore /[ \t\n\r\v]+/ } def attr [id '=' id] def open_tag ['<' id attr* '>'] def close_tag ['<' '/' id '>'] def tag [open_tag item* close_tag] def item [tag] | [id] Tag: tag = parse tag( stdin ) # Style: List of literal text and types. match Tag ["" item* ""] # Style: Literal text with embedded lists of types. match Tag "[item*]" print( Val1 '\n' ) print( Val2 '\n' )