コード例 #1
0
ファイル: cyprus.py プロジェクト: gatesphere/cyprus
        if opt == '-p': ptree = True
        elif opt == "-V": pverbose = True
        elif opt == '-v': pversion = True
        elif opt == '-h': phelp = True
    if pversion:
        version()
        sys.exit()
    if len(args) != 1 or phelp:
        usage()
        sys.exit()

    filename = args[0]

    if ptree:
        try:
            print parser.ptree(parser.parse(lexer.tokenizefile(filename)))
        except NoParseError as e:
            print "Could not parse file:"
            print e.msg
        sys.exit()

    ## actual logic
    try:
        tree = parser.parse(lexer.tokenizefile(filename))
    except NoParseError as e:
        print "Could not parse file:"
        print e.msg
        sys.exit()
    try:
        tree = CyprusProgram(tree)
        tree.run(verbose=pverbose)
コード例 #2
0
## cyprus
## parser test
## PeckJ 20121120
##

import sys
sys.path.append('..')
import cyprus_parser as parser
import cyprus_lexer as lexer
from funcparserlib.parser import NoParseError

if __name__ == '__main__':
  try:
    tree = parser.parse(lexer.tokenizefile('test.cyp'))  
    print parser.ptree(tree)
  except NoParseError as e:
    print e
コード例 #3
0
ファイル: cyprus.py プロジェクト: gatesphere/cyprus
   if   opt == '-p': ptree = True
   elif opt == "-V": pverbose = True
   elif opt == '-v': pversion = True
   elif opt == '-h': phelp = True
 if pversion:
   version()
   sys.exit()
 if len(args) != 1 or phelp:
   usage()
   sys.exit()
 
 filename = args[0]
 
 if ptree:
   try:
     print parser.ptree(parser.parse(lexer.tokenizefile(filename)))
   except NoParseError as e:
     print "Could not parse file:"
     print e.msg
   sys.exit()
 
 ## actual logic
 try:
   tree = parser.parse(lexer.tokenizefile(filename))
 except NoParseError as e:
   print "Could not parse file:"
   print e.msg
   sys.exit()
 try:
   tree = CyprusProgram(tree)
   tree.run(verbose=pverbose)