Comments (3)
Ok, I think I see the issue. '\n' is being added after input(), but it is never removed during the digit extraction loop. In the next request '\n' is still there in the input buffer, so "if not self._input_buffer" is false and input doesn't get called again, leading to no digits being extracted and the exception. Removing the '\n' and adding a length check to the digit extraction loop seems to fix it... not sure if this affects char reading though.
def _run_input(self, input_op, character):
if not self._input_buffer:
try:
self._input_buffer = input()
except EOFError:
if input_op.input_char:
self._character_opposite(character).value = -1
return
else:
raise Exception('End of file encountered.')
if input_op.input_number:
number_input = ''
while self._input_buffer and self._input_buffer[0].isdigit():
number_input += self._input_buffer[0]
self._input_buffer = self._input_buffer[1:]
if len(number_input) == 0:
raise Exception('No numeric input was given.')
self._character_opposite(character).value = int(number_input)
elif input_op.input_char:
input_char = ord(self._input_buffer[0])
self._input_buffer = self._input_buffer[1:]
self._character_opposite(character).value = input_char
from shakespearelang.
@Praxidice Thank you for reporting the issue! I'm finally doing a maintenance pass on shakespearelang and I think I've found a good fix for this.
Unfortunately, the numeric input functionality of SPL was not well-defined and the behavior I made up has been somewhat buggy and surprising.
I've revised numeric input in my latest change so that requesting a number will consume all consecutive digits at the start of the input, and an optional line break. If the line break is not present, nothing more is consumed so that the rest of the line can be read as characters.
I'll close this issue when the fix is released.
from shakespearelang.
A bit late here (it's been out since January) but 1.0.0rc1
fixes this issue -- feel free to test it out!
from shakespearelang.
Related Issues (9)
- SyntaxError in `shakespeare_interpreter.py`
- Undeclared dependency on grako
- Integers are read from (and written to) separate lines HOT 4
- FailedParse exception when trying to use difference HOT 1
- "If so" should accept any statement, not only "Let us..." HOT 2
- AI HOT 1
- PyPI Version Incorrect? HOT 1
- No module named 'readline' HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shakespearelang.