##### LM ##### context maxlen # # Regular Definitions # rl rl_ws /[ \t\n\r\v]+/ rl rl_id /[a-zA-Z_][a-zA-Z0-9_]*/ # # Tokens # lex ignore /rl_ws/ token id /rl_id/ end num: int allow: int def item [id] { num = num + 1 toomuch: int = allow+1 if num == toomuch { reject } } def open [] { num = 0 } def close [] def restricted_list [open item*] def start [restricted_list id*] end # maxlen cons MaxLen: maxlen[] MaxLen.allow = 3 parse S: maxlen::start(MaxLen)[stdin] print_xml( S ) print('\n') ##### IN ##### a b c d e f g ##### EXP ##### abcdefg