import sys from mmtype import MMType %% parser MMTypesParser: ignore: "(#.*?)?\n" token START: "^" token EOF: "$" token NAME: "[a-zA-Z0-9_]+" token VALUE: "0x[0-9A-F]{4}" token TYPES: "REQ|CNF|IND|RSP" token SPACE: "[ \t]+" rule parse: {{ mmtypes = [] }} (line {{ mmtypes.append (line) }} )* EOF {{ return mmtypes }} rule line: NAME SPACE VALUE types {{return MMType (NAME, VALUE, types)}} rule types: SPACE TYPES {{ v = [TYPES] }} ( SPACE TYPES {{ v.append (TYPES) }} )* {{ return v }}