Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsley.makeGrammar("death = ('a' | ws)*", {})('a ').death() # never returns? #67

Closed
kurtbrose opened this issue Dec 8, 2016 · 1 comment

Comments

@kurtbrose
Copy link

kurtbrose commented Dec 8, 2016

parsley.makeGrammar("death = ('a' | ws)*", {})('a ').death()  # never returns
parsley.makeGrammar("death = ('a' | (' ' | '\t' | '\n')*)*", {})('a ').death()  # never returns
parsley.makeGrammar("death = ('a' | ' '*)*", {})('a ').death()  # never returns
parsley.makeGrammar("death = ('a' | 'b'*)*", {})('ab').death()  # never returns
parsley.makeGrammar("never_returns = ('a'*)*", {})('a').never_returns()

Here are some nearby constructions that work okay:

parsley.makeGrammar("ok = ('a' | ' ')*", {})('a ').ok()  # returns ['a', ' ']
parsley.makeGrammar("ok = 'a' ws", {})('a ').ok()  # returns True
parsley.makeGrammar("ok = ('a' ws)*", {})('a ').ok()  # returns [True]
parsley.makeGrammar("ok = ('a' | ' ' | '\t' | '\n')*", {})('a ').ok()  # returns ['a', ' ']

Here's the stack trace when I manually terminate the never returning grammar:

KeyboardInterruptTraceback (most recent call last)
<ipython-input-65-b38e7b74e28c> in <module>()
----> 1 parsley.makeGrammar("death = ('a' | ws)*", {})('a ').death()

/home/notebook/anaconda2/lib/python2.7/site-packages/parsley.pyc in invokeRule(*args, **kwargs)
     83             """
     84             try:
---> 85                 ret, err = self._grammar.apply(name, *args)
     86             except ParseError as e:
     87                 self._grammar.considerError(e)

/home/notebook/anaconda2/lib/python2.7/site-packages/ometa/runtime.pyc in apply(self, ruleName, *args)
    460         r = getattr(self, "rule_"+ruleName, None)
    461         if r is not None:
--> 462             val, err = self._apply(r, ruleName, args)
    463             return val, err
    464 

/home/notebook/anaconda2/lib/python2.7/site-packages/ometa/runtime.pyc in _apply(self, rule, ruleName, args)
    493             try:
    494                 memoRec = self.input.setMemo(ruleName,
--> 495                                          [rule(), self.input])
    496             except ParseError as e:
    497                 e.trail.append(ruleName)

/pymeta_generated_code/pymeta_grammar__Grammar.py in rule_death(self)
     20                             self._trace("'\n'", (28, 31), self.input.position)
     21                             _G_exactly_8, lastError = self.exactly('\n')
---> 22                             self.considerError(lastError, None)
     23                             return (_G_exactly_8, self.currentError)
     24                         _G_not_9, lastError = self._not(_G_not_7)

/home/notebook/anaconda2/lib/python2.7/site-packages/ometa/runtime.pyc in many(self, fn, *initial)
    552             try:
    553                 m = self.input
--> 554                 v, _ = fn()
    555                 ans.append(v)
    556             except ParseError as err:

/pymeta_generated_code/pymeta_grammar__Grammar.py in _G_many_1()
     17                         return (_G_exactly_5, self.currentError)
     18                     def _G_or_6():
---> 19                         def _G_not_7():
     20                             self._trace("'\n'", (28, 31), self.input.position)
     21                             _G_exactly_8, lastError = self.exactly('\n')

/home/notebook/anaconda2/lib/python2.7/site-packages/ometa/runtime.pyc in _or(self, fns)
    596             try:
    597                 m = self.input
--> 598                 ret, err = f()
    599                 errors.append(err)
    600                 return ret, joinErrors(errors)

/pymeta_generated_code/pymeta_grammar__Grammar.py in _G_or_2()
      9             _G_exactly_1, lastError = self.exactly('//')
     10             self.considerError(lastError, 'c_comment')
---> 11             def _G_consumedby_2():
     12                 def _G_many_3():
     13                     def _G_or_4():

/home/notebook/anaconda2/lib/python2.7/site-packages/ometa/runtime.pyc in exactly(self, wanted)
    529             val, p, self.input = self.input.slice(len(wanted))
    530         else:
--> 531             val, p = self.input.head()
    532             self.input = self.input.tail()
    533         if wanted == val:

/home/notebook/anaconda2/lib/python2.7/site-packages/ometa/runtime.pyc in head(self)
    235             else:
    236                 data = self.data
--> 237             raise EOFError(data, self.position + 1)
    238         return self.data[self.position], self.error
    239 

/home/notebook/anaconda2/lib/python2.7/site-packages/ometa/runtime.pyc in __init__(self, input, position)
    113     """
    114     def __init__(self, input, position):
--> 115         ParseError.__init__(self, input, position, eof())
    116 
    117 

/home/notebook/anaconda2/lib/python2.7/site-packages/ometa/runtime.pyc in eof()
    125 
    126 
--> 127 def eof():
    128     """
    129     Return an indication that the end of the input was reached.

KeyboardInterrupt: 
@kurtbrose
Copy link
Author

oops, duplicate of #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant