revert changes in ncontrib

This commit is contained in:
Jim Shaver 2015-05-31 07:59:00 -04:00
parent b51363b3ca
commit bd019a7124
2 changed files with 21 additions and 21 deletions

View File

@ -216,7 +216,7 @@ class Beautifier:
parser_pos = 0 parser_pos = 0
while True: while True:
token_text, token_type = self.get_next_token() token_text, token_type = self.get_next_token()
#print(token_text, token_type, self.flags.mode) #print (token_text, token_type, self.flags.mode)
if token_type == 'TK_EOF': if token_type == 'TK_EOF':
break break

View File

@ -40,7 +40,7 @@ Here is a program to parse "Hello, World!" (or any greeting of the form "<saluta
greet = Word( alphas ) + "," + Word( alphas ) + "!" greet = Word( alphas ) + "," + Word( alphas ) + "!"
hello = "Hello, World!" hello = "Hello, World!"
print(hello, "->", greet.parseString( hello )) print hello, "->", greet.parseString( hello )
The program outputs the following:: The program outputs the following::
@ -651,13 +651,13 @@ def line( loc, strg ):
return strg[lastCR+1:] return strg[lastCR+1:]
def _defaultStartDebugAction( instring, loc, expr ): def _defaultStartDebugAction( instring, loc, expr ):
print("Match " + _ustr(expr) + " at loc " + _ustr(loc) + "(%d,%d)" % ( lineno(loc,instring), col(loc,instring) )) print ("Match " + _ustr(expr) + " at loc " + _ustr(loc) + "(%d,%d)" % ( lineno(loc,instring), col(loc,instring) ))
def _defaultSuccessDebugAction( instring, startloc, endloc, expr, toks ): def _defaultSuccessDebugAction( instring, startloc, endloc, expr, toks ):
print("Matched " + _ustr(expr) + " -> " + str(toks.asList())) print ("Matched " + _ustr(expr) + " -> " + str(toks.asList()))
def _defaultExceptionDebugAction( instring, loc, expr, exc ): def _defaultExceptionDebugAction( instring, loc, expr, exc ):
print("Exception raised:" + _ustr(exc)) print ("Exception raised:" + _ustr(exc))
def nullDebugAction(*args): def nullDebugAction(*args):
"""'Do-nothing' debug action, to suppress debugging output during parsing.""" """'Do-nothing' debug action, to suppress debugging output during parsing."""
@ -804,7 +804,7 @@ class ParserElement(object):
numargs -= 1 numargs -= 1
#~ print("adding function %s with %d args" % (f.func_name,numargs)) #~ print ("adding function %s with %d args" % (f.func_name,numargs))
if numargs == 3: if numargs == 3:
return f return f
else: else:
@ -914,7 +914,7 @@ class ParserElement(object):
debugging = ( self.debug ) #and doActions ) debugging = ( self.debug ) #and doActions )
if debugging or self.failAction: if debugging or self.failAction:
#~ print("Match",self,"at loc",loc,"(%d,%d)" % ( lineno(loc,instring), col(loc,instring) )) #~ print ("Match",self,"at loc",loc,"(%d,%d)" % ( lineno(loc,instring), col(loc,instring) ))
if (self.debugActions[0] ): if (self.debugActions[0] ):
self.debugActions[0]( instring, loc, self ) self.debugActions[0]( instring, loc, self )
if callPreParse and self.callPreparse: if callPreParse and self.callPreparse:
@ -928,7 +928,7 @@ class ParserElement(object):
except IndexError: except IndexError:
raise ParseException( instring, len(instring), self.errmsg, self ) raise ParseException( instring, len(instring), self.errmsg, self )
except ParseBaseException, err: except ParseBaseException, err:
#~ print("Exception raised:", err) #~ print ("Exception raised:", err)
if self.debugActions[2]: if self.debugActions[2]:
self.debugActions[2]( instring, tokensStart, self, err ) self.debugActions[2]( instring, tokensStart, self, err )
if self.failAction: if self.failAction:
@ -962,7 +962,7 @@ class ParserElement(object):
asList=self.saveAsList and isinstance(tokens,(ParseResults,list)), asList=self.saveAsList and isinstance(tokens,(ParseResults,list)),
modal=self.modalResults ) modal=self.modalResults )
except ParseBaseException, err: except ParseBaseException, err:
#~ print("Exception raised in user parse action:", err) #~ print ("Exception raised in user parse action:", err)
if (self.debugActions[2] ): if (self.debugActions[2] ):
self.debugActions[2]( instring, tokensStart, self, err ) self.debugActions[2]( instring, tokensStart, self, err )
raise raise
@ -976,7 +976,7 @@ class ParserElement(object):
modal=self.modalResults ) modal=self.modalResults )
if debugging: if debugging:
#~ print("Matched",self,"->",retTokens.asList()) #~ print ("Matched",self,"->",retTokens.asList())
if (self.debugActions[1] ): if (self.debugActions[1] ):
self.debugActions[1]( instring, tokensStart, loc, self, retTokens ) self.debugActions[1]( instring, tokensStart, loc, self, retTokens )
@ -2861,7 +2861,7 @@ class SkipTo(ParseElementEnhance):
while 1: while 1:
try: try:
loc = self.ignoreExpr.tryParse(instring,loc) loc = self.ignoreExpr.tryParse(instring,loc)
print("found ignoreExpr, advance to", loc) print "found ignoreExpr, advance to", loc
except ParseBaseException: except ParseBaseException:
break break
expr._parse( instring, loc, doActions=False, callPreParse=False ) expr._parse( instring, loc, doActions=False, callPreParse=False )
@ -3239,7 +3239,7 @@ def oneOf( strs, caseless=False, useRegex=True ):
i += 1 i += 1
if not caseless and useRegex: if not caseless and useRegex:
#~print(strs,"->", "|".join( [ _escapeRegexChars(sym) for sym in symbols] )) #~ print (strs,"->", "|".join( [ _escapeRegexChars(sym) for sym in symbols] ))
try: try:
if len(symbols)==len("".join(symbols)): if len(symbols)==len("".join(symbols)):
return Regex( "[%s]" % "".join( [ _escapeRegexRangeChars(sym) for sym in symbols] ) ) return Regex( "[%s]" % "".join( [ _escapeRegexRangeChars(sym) for sym in symbols] ) )
@ -3669,16 +3669,16 @@ if __name__ == "__main__":
try: try:
tokens = simpleSQL.parseString( teststring ) tokens = simpleSQL.parseString( teststring )
tokenlist = tokens.asList() tokenlist = tokens.asList()
print(teststring + "->" + str(tokenlist)) print (teststring + "->" + str(tokenlist))
print("tokens = " + str(tokens)) print ("tokens = " + str(tokens))
print("tokens.columns = " + str(tokens.columns)) print ("tokens.columns = " + str(tokens.columns))
print("tokens.tables = " + str(tokens.tables)) print ("tokens.tables = " + str(tokens.tables))
print(tokens.asXML("SQL",True)) print (tokens.asXML("SQL",True))
except ParseBaseException,err: except ParseBaseException,err:
print(teststring + "->") print (teststring + "->")
print(err.line) print (err.line)
print(" "*(err.column-1) + "^") print (" "*(err.column-1) + "^")
print(err) print (err)
print() print()
selectToken = CaselessLiteral( "select" ) selectToken = CaselessLiteral( "select" )