Fix the COBOL Schema Parser Functions

The revised version of COBOL_schemata looks like this:

def COBOL_schemata( source, replacing=None, lexer_class=Lexer ):
    lexer= lexer_class( replacing )
    parser= RecordFactory()
    dde_list= list( parser.makeRecord( lexer.scan(source) ) )
    schema_list= list( make_schema( dde ) for dde in dde_list )
    return dde_list, schema_list

This gives us an API that looks like this:

dde_list, schema_list = stingray.cobol.loader.COBOL_schemata( 
    source, lexer_class=cobol.loader.Lexer_Long_Lines )

We can include the lexer without having to rewrite the function explicitly.

We can then pick apart the parsed results.

self.record_1, self.record_2 = dde_list
self.schema_1, self.schema_2 = schema_list
Posted by Steven F. Lott 2014-06-07

Log in to post a comment.