Exemplo n.º 1
0
        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)
Exemplo n.º 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
Exemplo n.º 3
0
   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)