Ejemplo n.º 1
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
Ejemplo n.º 2
0
## cyprus
## lexer test
## PeckJ 20121120
##

import sys

sys.path.append('..')
import cyprus_lexer as lexer

if __name__ == '__main__':
    ts = lexer.tokenizefile('test.cyp')
    for t in ts:
        print t.__unicode__()
Ejemplo 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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
## cyprus
## lexer test
## PeckJ 20121120
##

import sys
sys.path.append('..')
import cyprus_lexer as lexer

if __name__ == '__main__':
  ts = lexer.tokenizefile('test.cyp')
  for t in ts:
    print t.__unicode__()