# # Tokens # # Any single character can be a literal lex start { # Ignore whitespace. ignore /[ \t\n\r\v]+/ # Open and close id token id /[a-zA-Z_][a-zA-Z0-9_]*/ token open_paren /'('/ { parse_stop NC: nested_comment( stdin ) print( %NC '\n' ) input.push_ignore( NC ) } } # # Token translation # lex nc_scan { literal '(', ')' token nc_data /[^()]+/ } def nc_item [nc_data] | [nested_comment] def nested_comment ['(' nc_item* ')'] def nested [id*] P: nested = parse nested( stdin ) print( ^P '\n' ) print_xml( ^P ) print( '\n' ) print_xml_ac( ^P ) print( '\n' ) print( ^P '\n' )