def _getGerberGrammar(self):
     
       gerber_dictionary = {
           "G04": { "text": "comment" },   
           "G36": { "text": "closed-shape-start" }, 
           "G37": { "text": "closed-shape-end" },
     
           "MO": { "text": "units",
                   "MM": { "text": "mm" },
                   "IN": { "text": "inch" }
                 },
     
           "AD": { "text": "aperture-definition",
                   "C": { "text": "circle" },
                   "R": { "text": "rectangle" }
                 },
     
           "FS": { "text": "format" ,
                   "L": { "text": "leading-zeros" },
                   "A": { "text": "absolute" }
                 },
           
           "D01": { "text": "draw"},
           "D02": { "text": "move"},
           "D03": { "text": "flash"}
       }
     
       # Define grammar using pyparsing
       space = pyp.Literal(' ')
       comma = pyp.Literal(',').suppress()
     
       # Capture a float string and cast to float
       floatnum = pyp.Regex(r'([\d\.]+)').setParseAction(lambda t: float(t[0]))
     
       # Capture integer string and cast to int
       integer = pyp.Regex(r'(-?\d+)').setParseAction(lambda t: int(t[0]))
     
       # Capture single digit string and cast to int
       single_digit = pyp.Regex(r'(\d)').setParseAction(lambda t: int(t[0]))
     
       aperture = pyp.Literal('D').setParseAction(pyp.replaceWith('aperture'))
       coord_x = pyp.Literal('X').setParseAction(pyp.replaceWith('x'))
       coord_y = pyp.Literal('Y').setParseAction(pyp.replaceWith('y'))
       gcoord = pyp.Regex(r'(-?\d+)')
       coord_dict = pyp.dictOf((coord_x | coord_y), gcoord)
       coord_xy = pyp.Group(coord_dict + coord_dict)
     
       inst_del = pyp.Literal('%').suppress() # instruction delimeter
       inst_end = pyp.Literal('*').suppress() # ending suffix
     
       cmd_comment = pyp.Literal('G04').setParseAction(pyp.replaceWith('comment'))
     
       cmd_closed_shape_start = pyp.Literal('G36')
       cmd_closed_shape_end = pyp.Literal('G37')
     
       cmd_units = pyp.Literal('MO')('gerber-command')
       cmd_units_opt_mm = pyp.Literal('MM').setParseAction(pyp.replaceWith('mm'))
       cmd_units_opt_inch = pyp.Literal('IN').setParseAction(pyp.replaceWith('inch'))
     
       cmd_format = pyp.Literal('FS')('gerber-command')
       cmd_format_opt_leading_zeros = pyp.Literal('L').setParseAction(pyp.replaceWith('leading'))
       cmd_format_opt_trailing_zeros = pyp.Literal('T').setParseAction(pyp.replaceWith('trailing'))
     
       cmd_format_opt_absolute = pyp.Literal('A').setParseAction(pyp.replaceWith('absolute')) 
       cmd_format_opt_incremental = pyp.Literal('I').setParseAction(pyp.replaceWith('incremental')) 
     
       # Aperture definition
       cmd_ap_def = pyp.Literal('AD')('gerber-command')
       cmd_ap_def_num = 'D' + integer.setResultsName('number')
       cmd_ap_def_opt_circ = pyp.Literal('C').setParseAction(pyp.replaceWith('circle'))
       cmd_ap_def_opt_rect = pyp.Literal('R').setParseAction(pyp.replaceWith('rect'))
     
       cmd_polarity = pyp.Literal('LP')('gerber-command')
       cmd_polarity_opt_dark = pyp.Literal('D').setParseAction(pyp.replaceWith('dark'))
       cmd_polarity_opt_clear = pyp.Literal('C').setParseAction(pyp.replaceWith('clear'))
     
       cmd_linear_int = pyp.Literal('G01').suppress() # lineal interpolation
       cmd_circ_int_cw = pyp.Literal('G02').suppress() # circular int. clockwise
       cmd_circ_int_ccw = pyp.Literal('G03').suppress() # circular int. counter-clockwise
     
       aperture_type = (((cmd_ap_def_opt_circ('type') + comma) + (floatnum)('diameter') + 'X') | 
                        ((cmd_ap_def_opt_rect('type') + comma) + (floatnum)('width') + 'X' + (floatnum)('height'))) 
     
       polarity_type = (cmd_polarity_opt_clear | cmd_polarity_opt_dark)('polarity')
     
       units_type = (cmd_units_opt_mm | cmd_units_opt_inch)('units')
     
       format_zeros = ((cmd_format_opt_leading_zeros('zeros')) |
                       (cmd_format_opt_trailing_zeros('zeros')))
     
       format_notation = ((cmd_format_opt_absolute('notation')) |
                          (cmd_format_opt_incremental('notation')))
     
       format_data = (single_digit)('integer') + single_digit('decimal')
     
       # comments (suppress)
       comment = (cmd_comment + 
                  pyp.Optional(space) + 
                  pyp.Regex(r"([^\*]+)?") + 
                  pyp.Optional(space) + 
                  inst_end).suppress()
     
       units = (inst_del +
                pyp.Group(cmd_units +
                units_type)('units') +  
                inst_end + 
                inst_del)
     
       gformat = (inst_del +
                  pyp.Group(cmd_format +
                  format_zeros +
                  format_notation +
                  'X' + pyp.Group(format_data)('x') + 
                  'Y' + pyp.Group(format_data)('y'))('format') + 
                  inst_end +
                  inst_del)
     
       ap_def = (inst_del + 
                  pyp.Group(cmd_ap_def +
                  cmd_ap_def_num +
                  aperture_type)('aperture_definition') +
                  inst_end +
                  inst_del)
     
       polarity = (inst_del +
                   pyp.Group(cmd_polarity +
                   polarity_type)('polarity_change') +
                   inst_end +
                   inst_del)      
     
       closed_shape_start = (cmd_closed_shape_start('start_closed_shape') + inst_end)
       closed_shape_end = (cmd_closed_shape_end('end_closed_shape') + inst_end)
     
       draw = pyp.Group(pyp.Optional(cmd_linear_int) +
               'X' + (integer)('x') +
               'Y' + (integer)('y') +
               pyp.Literal('D01').suppress() +
               inst_end)('draw')
     
       move = pyp.Group(pyp.Optional(cmd_linear_int) +
               'X' + (integer)('x') +
               'Y' + (integer)('y') +
               pyp.Literal('D02').suppress() +
               inst_end)('move')
     
       flash = pyp.Group(pyp.Optional(cmd_linear_int) +
               'X' + (integer)('x') +
               'Y' + (integer)('y') +
               pyp.Literal('D03').suppress() +
               inst_end)('flash')
     
       aperture_change = (pyp.Literal('D').suppress() + 
                          pyp.Group(integer('number') + inst_end)('aperture_change'))
     
       # end of file (suppress)
       the_end = (pyp.Literal('M02') + inst_end)('end_of_gerber')
     
     
       grammar = (comment | 
                  units | 
                  gformat | 
                  ap_def |
                  aperture_change |
                  draw | move | flash |
                  polarity |
                  closed_shape_start |
                  closed_shape_end |
                  the_end)
     
       
     
       return pyp.OneOrMore(pyp.Group(grammar))
Test tokenization of node names.
dataset/ETHPy150Open boldport/pcbmode/pcbmode/utils/gerber.py/Gerber._getGerberGrammar--crossover with--dataset/ETHPy150Open nltk/nltk/nltk/test/unit/test_tgrep.py/TestSequenceFunctions.test_tokenize_nodenames