示例#1
0
    def startLoop( self, line ) :
        print("Start loop in line %s" % line)
        return False
    def endLoop( self, line ) :
        print("End loop in line %s" % line)
        return False
    def data( self, tag, tagline, val, valline, delim, inloop ) :
        print("%s tag/value: %s : %s ( %s : %s ) d %s" % ( "Loop" if inloop else "Free", tag, sans.quote( val ), tagline, valline, delim))
        return False
    def fatalError( self, line, msg ) :
        print("parse fatal error in line %s : %s" % (line, msg))
        return True
    def error( self, line, msg ) :
        print("parse error in line %s : %s" % (line, msg))
        return True
    def warning( self, line, msg ) :
        print("parse warning in line %s : %s" % (line, msg))
        return False

#
#
#
if __name__ == "__main__" :
    l = sans.STARLexer( sys.stdin )
#    l.verbose = True
    t = Test()
    p = sans.parser( l, t, t )
    p.parse()
#
#
示例#2
0
文件: test.py 项目: fenglb/ccpnmr2.4
        if inloop: print "Loop",
        else: print "Free",
        print "tag/value:", tag, ":", sans.quote(
            val), "(", tagline, ":", valline, ") d", delim
        return False

    def fatalError(self, line, msg):
        print "parse fatal error in line", line, ":", msg
        return True

    def error(self, line, msg):
        print "parse error in line", line, ":", msg
        return True

    def warning(self, line, msg):
        print "parse warning in line", line, ":", msg
        return False


#
#
#
if __name__ == "__main__":
    l = sans.STARLexer(sys.stdin)
    l.verbose = True
    t = Test()
    p = sans.parser(l, t, t)
    p.parse()
#
#
示例#3
0
class Handler( sans.ContentHandler ) :
    def startData( self, line, name ) :
        return False
    def endData( self, line, name ) :
        pass
    def startSaveframe( self, line, name ) :
        return False
    def endSaveframe( self, line, name ) :
        return False
    def startLoop( self, line ) :
        return False
    def endLoop( self, line ) :
        return False
    def comment( self, line, text ) :
        return False
    def data( self, tag, tagline, val, valline, delim, inloop ) :
        print tag, ":", val
        return False


if __name__ == "__main__" :
    if len( sys.argv ) > 1 : 
        infile = open( sys.argv[1], "rb" )
    else : infile = sys.stdin
    l = sans.STARLexer( infile )
    e = sans.ErrorHandler()
    c = Handler()
    p = sans.parser( l, c, e )
    p.parse()
    if len( sys.argv ) > 1 : infile.close()