Skip to content

Commit

Permalink
Fix makefile, add bint declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Aug 2, 2017
1 parent 7872919 commit a3656a9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 45 deletions.
16 changes: 4 additions & 12 deletions Makefile
Expand Up @@ -62,24 +62,16 @@ test-3:

.PHONY: test-c
test-c:
pushd ./tests
make test-c
popd
pushd ./tests; make test-c; popd

.PHONY: test-py
test-py:
pushd ./tests
make test-py
popd
pushd ./tests; make test-py; popd

.PHONY: test-coconut-py
test-coconut-py:
pushd ./tests
make test-coconut-py
popd
pushd ./tests; make test-coconut-py; popd

.PHONY: test-coconut-c
test-coconut-c:
pushd ./tests
make test-coconut-c
popd
pushd ./tests; make test-coconut-c; popd
66 changes: 33 additions & 33 deletions cPyparsing.pyx
Expand Up @@ -1322,7 +1322,7 @@ class ParserElement(object):
self.failAction = fn
return self

def _skipIgnorables(self, instring, loc):
def _skipIgnorables(self, instring, int loc):
exprsFound = True
while exprsFound:
exprsFound = False
Expand All @@ -1347,14 +1347,14 @@ class ParserElement(object):

return loc

def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
return loc, []

def postParse(self, instring, int loc, tokenlist):
return tokenlist

#~ @profile
def _parseNoCache(self, instring, int loc, doActions=True, callPreParse=True):
def _parseNoCache(self, instring, int loc, bint doActions=True, bint callPreParse=True):
debugging = (self.debug) # and doActions )

if debugging or self.failAction:
Expand Down Expand Up @@ -1527,7 +1527,7 @@ class ParserElement(object):

# this method gets repeatedly called during backtracking with the same arguments -
# we can cache these arguments and save ourselves the trouble of re-parsing the contained expression
def _parseCache(self, instring, int loc, doActions=True, callPreParse=True):
def _parseCache(self, instring, int loc, bint doActions=True, bint callPreParse=True):
HIT, MISS = 0, 1
lookup = (self, instring, loc, callPreParse, doActions)
with ParserElement.packrat_cache_lock:
Expand Down Expand Up @@ -2383,7 +2383,7 @@ class NoMatch(Token):
self.mayIndexError = False
self.errmsg = "Unmatchable token"

def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
raise ParseException(instring, loc, self.errmsg, self)


Expand Down Expand Up @@ -2421,7 +2421,7 @@ class Literal(Token):
# if this is a single character match string and the first character matches,
# short-circuit as quickly as possible, and avoid calling startswith
#~ @profile
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if (instring[loc] == self.firstMatchChar and
(self.matchLen == 1 or instring.startswith(self.match, loc))):
return loc + self.matchLen, self.match
Expand Down Expand Up @@ -2472,7 +2472,7 @@ class Keyword(Token):
identChars = identChars.upper()
self.identChars = set(identChars)

def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if self.caseless:
if ((instring[loc:loc + self.matchLen].upper() == self.caselessmatch) and
(loc >= len(instring) - self.matchLen or instring[loc + self.matchLen].upper() not in self.identChars) and
Expand Down Expand Up @@ -2517,7 +2517,7 @@ class CaselessLiteral(Literal):
self.name = "'%s'" % self.returnString
self.errmsg = "Expected " + self.name

def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if instring[loc:loc + self.matchLen].upper() == self.match:
return loc + self.matchLen, self.returnString
raise ParseException(instring, loc, self.errmsg, self)
Expand All @@ -2536,7 +2536,7 @@ class CaselessKeyword(Keyword):
def __init__(self, matchString, identChars=None):
super(CaselessKeyword, self).__init__(matchString, identChars, caseless=True)

def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if ((instring[loc:loc + self.matchLen].upper() == self.caselessmatch) and
(loc >= len(instring) - self.matchLen or instring[loc + self.matchLen].upper() not in self.identChars)):
return loc + self.matchLen, self.match
Expand Down Expand Up @@ -2578,7 +2578,7 @@ class CloseMatch(Token):
self.mayIndexError = False
self.mayReturnEmpty = False

def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
start = loc
instrlen = len(instring)
maxloc = start + len(self.match_string)
Expand Down Expand Up @@ -2707,7 +2707,7 @@ class Word(Token):
except Exception:
self.re = None

def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if self.re:
result = self.re.match(instring, loc)
if not result:
Expand Down Expand Up @@ -2813,7 +2813,7 @@ class Regex(Token):
self.mayIndexError = False
self.mayReturnEmpty = True

def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
result = self.re.match(instring, loc)
if not result:
raise ParseException(instring, loc, self.errmsg, self)
Expand Down Expand Up @@ -2929,7 +2929,7 @@ class QuotedString(Token):
self.mayIndexError = False
self.mayReturnEmpty = True
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
result = instring[loc] == self.firstQuoteChar and self.re.match(instring, loc) or None
if not result:
raise ParseException(instring, loc, self.errmsg, self)
Expand Down Expand Up @@ -3017,7 +3017,7 @@ class CharsNotIn(Token):
self.mayReturnEmpty = (self.minLen == 0)
self.mayIndexError = False
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if instring[loc] in self.notChars:
raise ParseException(instring, loc, self.errmsg, self)
Expand Down Expand Up @@ -3085,7 +3085,7 @@ class White(Token):
self.maxLen = exact
self.minLen = exact
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if not(instring[loc] in self.matchWhite):
raise ParseException(instring, loc, self.errmsg, self)
start = loc
Expand Down Expand Up @@ -3127,7 +3127,7 @@ class GoToColumn(_PositionToken):
loc += 1
return loc
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
thiscol = col(loc, instring)
if thiscol > self.col:
raise ParseException(instring, loc, "Text not in expected column", self)
Expand Down Expand Up @@ -3162,7 +3162,7 @@ class LineStart(_PositionToken):
super(LineStart, self).__init__()
self.errmsg = "Expected start of line"
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if col(loc, instring) == 1:
return loc, []
raise ParseException(instring, loc, self.errmsg, self)
Expand All @@ -3178,7 +3178,7 @@ class LineEnd(_PositionToken):
self.setWhitespaceChars(ParserElement.DEFAULT_WHITE_CHARS.replace("\n", ""))
self.errmsg = "Expected end of line"
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if loc < len(instring):
if instring[loc] == "\n":
return loc + 1, "\n"
Expand All @@ -3199,7 +3199,7 @@ class StringStart(_PositionToken):
super(StringStart, self).__init__()
self.errmsg = "Expected start of text"
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if loc != 0:
# see if entire string up to here is just whitespace and ignoreables
if loc != self.preParse(instring, 0):
Expand All @@ -3216,7 +3216,7 @@ class StringEnd(_PositionToken):
super(StringEnd, self).__init__()
self.errmsg = "Expected end of text"
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if loc < len(instring):
raise ParseException(instring, loc, self.errmsg, self)
elif loc == len(instring):
Expand All @@ -3241,7 +3241,7 @@ class WordStart(_PositionToken):
self.wordChars = set(wordChars)
self.errmsg = "Not at the start of a word"
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if loc != 0:
if (instring[loc - 1] in self.wordChars or
instring[loc] not in self.wordChars):
Expand All @@ -3264,7 +3264,7 @@ class WordEnd(_PositionToken):
self.skipWhitespace = False
self.errmsg = "Not at the end of a word"
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
instrlen = len(instring)
if instrlen > 0 and loc < instrlen:
if (instring[loc] in self.wordChars or
Expand Down Expand Up @@ -3416,7 +3416,7 @@ class And(ParseExpression):
self.skipWhitespace = self.exprs[0].skipWhitespace
self.callPreparse = True
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
# pass False as last arg to _parse for first element, since we already
# pre-parsed the string as part of our And pre-parsing
loc, resultlist = self.exprs[0]._parse(instring, loc, doActions, callPreParse=False)
Expand Down Expand Up @@ -3485,7 +3485,7 @@ class Or(ParseExpression):
else:
self.mayReturnEmpty = True
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
maxExcLoc = -1
maxException = None
matches = []
Expand Down Expand Up @@ -3567,7 +3567,7 @@ class MatchFirst(ParseExpression):
else:
self.mayReturnEmpty = True
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
maxExcLoc = -1
maxException = None
for e in self.exprs:
Expand Down Expand Up @@ -3672,7 +3672,7 @@ class Each(ParseExpression):
self.skipWhitespace = True
self.initExprGroups = True
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if self.initExprGroups:
self.opt1map = dict((id(e.expr), e) for e in self.exprs if isinstance(e, Optional))
opt1 = [e.expr for e in self.exprs if isinstance(e, Optional)]
Expand Down Expand Up @@ -3759,7 +3759,7 @@ class ParseElementEnhance(ParserElement):
self.callPreparse = expr.callPreparse
self.ignoreExprs.extend(expr.ignoreExprs)
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if self.expr is not None:
return self.expr._parse(instring, loc, doActions, callPreParse=False)
else:
Expand Down Expand Up @@ -3836,7 +3836,7 @@ class FollowedBy(ParseElementEnhance):
super(FollowedBy, self).__init__(expr)
self.mayReturnEmpty = True
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
self.expr.tryParse(instring, loc)
return loc, []
Expand All @@ -3860,7 +3860,7 @@ class NotAny(ParseElementEnhance):
self.mayReturnEmpty = True
self.errmsg = "Found unwanted token, " + _ustr(self.expr)
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
if self.expr.canParseNext(instring, loc):
raise ParseException(instring, loc, self.errmsg, self)
return loc, []
Expand All @@ -3884,7 +3884,7 @@ class _MultipleMatch(ParseElementEnhance):
ender = ParserElement._literalStringClass(ender)
self.not_ender = ~ender if ender is not None else None
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
self_expr_parse = self.expr._parse
self_skip_ignorables = self._skipIgnorables
check_ender = self.not_ender is not None
Expand Down Expand Up @@ -3967,7 +3967,7 @@ class ZeroOrMore(_MultipleMatch):
super(ZeroOrMore, self).__init__(expr, stopOn=stopOn)
self.mayReturnEmpty = True
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
try:
return super(ZeroOrMore, self).parseImpl(instring, loc, doActions)
except (ParseException, IndexError):
Expand Down Expand Up @@ -4037,7 +4037,7 @@ class Optional(ParseElementEnhance):
self.defaultValue = default
self.mayReturnEmpty = True
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
try:
loc, tokens = self.expr._parse(instring, loc, doActions, callPreParse=False)
except (ParseException, IndexError):
Expand Down Expand Up @@ -4134,7 +4134,7 @@ class SkipTo(ParseElementEnhance):
self.failOn = failOn
self.errmsg = "No match found for " + _ustr(self.expr)
def parseImpl(self, instring, int loc, doActions=True):
def parseImpl(self, instring, int loc, bint doActions=True):
startloc = loc
instrlen = len(instring)
expr = self.expr
Expand Down

0 comments on commit a3656a9

Please sign in to comment.