Comments (8)
This error also occurs when a whitespace character (tab, space or newline) is placed after a debug flag (valid or invalid). Unlike the debug flags at the end of the program when debug flags are followed by a space the invalid character is labeled as the correct whitespace and a period.
It seems that the whitespace is considered part of a debug flag when the program is being stripped of extra characters but not part of a debug flag when the debug flags are added. This however does not explain why debug flags at the ends of programs result in the same error. Perhaps when the interpreter reads from the file it adds an extra newline to the end of string if none is present.
Example
Code
()#dc ()
Without Debug
$ ruby brain_flak.rb code.txt
Error at character 3: Invalid character ' .'
With Debug
$ ruby brain_flak.rb code.txt
Debug mode... ENGAGED!
#dc (left) []
Error at character 3: Invalid character ' .'
from brain-flak.
The reason there is always a period quoted with the invalid character is because there was a typo in the error message. The line (138/154 as of 3aa842b):
else raise BrainFlakError.new("Invalid character '%s.'" % current_symbol, @index + 1)
should have been:
else raise BrainFlakError.new("Invalid character '%s'." % current_symbol, @index + 1)
This typo although initially confusing is entirely inconsequential to the bug as a whole. It doesn't deserve its own commit (Especially because this error message only appears if there is a bug in the interpreter). The change should probably be bundled with the final fix for this bug.
from brain-flak.
I fixed a similar bug while I was finishing up the debug flags (commit a839fbe) but I just went back and checked and it appears to have popped back in when I merged the debug flags branch into master (commit 0e607e1) but my previous fix is still in the code so it must be something else.
from brain-flak.
Hmmm... your whitespace fix has the problem where the #dv
in ()#dv foo
is no longer recognized as a debug flag
from brain-flak.
I got a fix, the regex at the start of the initializer of Interpreter
needed to have a +
changed to a *
so that if it encountered a lone whitespace character it matched it as opposed to passing over it.
from brain-flak.
Pull request #29 should do the trick, but if anyone wants to do more extensive testing that would definitely be a good idea
from brain-flak.
Tangentially related to this issue:
Should #dv8
be considered a valid flag? Should we truncate the 8
to make the #dv
. If #dv
is considered a valid flag and whitespace is considered an invalid character just as 8
is shouldn't both of them behave the same way?
from brain-flak.
It would be a good idea to hammer out which characters can be considered part of a debug flag. My reason for excluding whitespace from debug flags because I felt it would be confusing to have if, for example, there was a program that had a debug flag followed by a new line like so
()#dv
a comment ()
If whitespace were allowed to be part of debug flags then it would not recognize that #dv
as a debug flag. So I decided to have the interpreter exclude whitespace from debug flags, but I did not put any further thought to it.
from brain-flak.
Related Issues (20)
- Logo HOT 4
- Debug Flag Documentation HOT 4
- Comments don't work on the last line of a program
- Unicode to decimal HOT 7
- Debug flags following a whitespace at the beginning of a program error HOT 1
- Lone @ symbols cause invalid character errors HOT 1
- Debug flags don't work properly when there is whitespace after the flag
- @ at the end of the program causes an error HOT 1
- Error messages are inconsistent? HOT 1
- Other languages HOT 4
- Comment your code? HOT 2
- Keyboard Interrupts don't work properly on TIO
- Chararacter HOT 2
- Mismatched Brackets HOT 4
- Invalid character is back HOT 1
- Cycle counting HOT 3
- Comments are read by Miniflak
- Flags are parsed even when not in debug mode
- Brain Flak classic no ascii output HOT 1
- Phasing out -a 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 brain-flak.