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