BlockIt
parsers.py
Go to the documentation of this file.
00001 #............................................................................
00002 # Copyright (c) 2009,2010,2011 David Car, david.car7@gmail.com
00003 #
00004 # This program is free software; you can redistribute it and/or modify it under
00005 # the terms of the GNU General Public License as published by the Free Software
00006 # Foundation; either version 2 of the License, or (at your option) any later
00007 # version.
00008 #
00009 # This program is distributed in the hope that it will be useful, but WITHOUT
00010 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU General Public License along with
00014 # this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00015 # Place, Suite 330, Boston, MA 02111-1307 USA
00016 #..........................................................................
00017 __all__ = ['FortranBlockParser']
00018 
00019 from blockit.parsers import BlockParser
00020 from blockit.blocks import Block
00021 from blockit.library import Library
00022 import os
00023 
00024 #..................
00025 # Block parser
00026 #..................
00027 class FortranBlockParser( BlockParser ):
00028     def __init__( self, scanner=None ):
00029         super( FortranBlockParser, self ).__init__( scanner, 
00030                                                     ignoreChars='!', 
00031                                                     contChar='&')
00032 
00033     def parse( self, startBlock ):
00034         scanner = self._scanner
00035         if scanner is None:
00036             raise Exception("No scanner attribute!  Use setScanner().")
00037         
00038         #....................................................................
00039         # LineScanner throws EOFError exception when finished.  Wrap in
00040         # try/except to catch that.  Any other errors are errors in parsing
00041         # the file
00042         #....................................................................
00043         try:
00044             blk = startBlock
00045 
00046             # Run the internal recursive parser
00047             self._parse( blk )
00048 
00049         except EOFError:
00050             blk.ignoreDependencies( blk.getIgnoreDependencies() )
00051             blk.removeDependencies( blk.getIgnoreDependencies() )
00052 
00053         else:
00054             print "Error in parsing file %s"%(blk.name(),)
00055 
00056         return blk
00057 
00058     def __propScanner():
00059         doc = "Return the scanner"
00060         def fget( self ):
00061             return self._scanner
00062         return locals()
00063 
00064     scanner = property( **__propScanner() )
00065         
00066 
All Classes Namespaces Files Functions Variables Properties