Exemplo n.º 1
0
    def test1(self):
        'parse file f3.f'

        f1 = Ffile.file(fname_t('f3.f'),
                        c_action=parse_cmnt,
                        s_action=parse_stmts)
        ok_s = (
            fs.Comments,
            fs.SubroutineStmt,
            fs.Comments,
            fs.AssignStmt,
            fs.Comments,
            fs.AssignStmt,
            fs.AssignStmt,
            fs.AssignStmt,
            fs.IfStmt,
            fs.AssignStmt,
            fs.AssignStmt,
            fs.WriteStmt,
            fs.OpenStmt,
            fs.FormatStmt,
            fs.Comments,
            fs.DoStmt,
            fs.AssignStmt,
            fs.EnddoStmt,
            fs.Comments,
            fs.EndStmt,
        )
        for (l, c) in izip(f1.lines, ok_s):
            a_(isinstance(l, c))
Exemplo n.º 2
0
def fortUnitIterator(fileName, inputFormat=None):
    '''
    returns an iterator over units found in the given file named fileName;
    the units are assembled based on install_pat
    and buf_iter provides the source iterator from which the units are assembled
    '''
    return vgen(install_pat(_curr(module_handler.ourModuleHandler)),
                buf_iter(Ffile.file(fileName,parse_cmnt,parse_stmts,\
                                    inputFormat).lines))
def fortPreUnitIterator(fileName,free):
    if free: inputFormat = 'free'
    else: inputFormat = 'fixed'
    return vgen(unit,buf_iter(Ffile.file(fileName,parse_cmnt,parse_stmts,inputFormat).lines))