sqs4.py
Go to the documentation of this file.
00001 #!c:/python26/python.exe
00002 import sys,rp
00003 rule=['init n=0',
00004       'init m=999',
00005       'sqs  ::=  range? parms  fileid ',
00006       'range::=  n "-" "*" ',
00007       '      |   n "-" m ',
00008           'n    ::=  r"[0-9]"* ',
00009           'm    ::=  r"[0-9]"* ',         
00010       'parms::=  sep car* sep ',
00011           'sep  ::=  r"\S" ',
00012           'car  ::=  r"." ^sep ',
00013           'fileid::= r"\S"* ']
00014 parms=' '.join(sys.argv[1:])
00015 
00016 cmp=rp.match(rule,parms)
00017 if cmp==None:
00018         print "Error in parsing:"
00019 else:
00020         id=None
00021         n=int(cmp.n)
00022         m=int(cmp.m)
00023         try:
00024                 id=open(cmp.fileid)
00025                 for l in id.readlines():
00026                         if l.find(cmp.car,n,m)>-1: 
00027                                 print l[:-1]
00028         except Exception,e:
00029                 print e
00030         else:
00031                 if id!=None: id.close()


rocon_ebnf
Author(s): LParis
autogenerated on Fri May 2 2014 10:35:48