kleinesfilmroellchen / sof-language

The Stack with Objects and Functions Programming Language, a pure stack-based reverse-polish-notation functional and object-oriented experimental programming language.
https://kleinesfilmroellchen.github.io/sof-language/
GNU General Public License v3.0
11 stars 0 forks source link

[bug] Preprocessor considers all curly braces, whether legal tokens or not #5

Closed kleinesfilmroellchen closed 4 years ago

kleinesfilmroellchen commented 4 years ago

Describe the bug

The Preprocessor tries to ensure that all code block braces match up. However, it primitively only checks the characters themselves, not whether they occur as a separate token. Therefore, curly braces which are part of a string (common, critical) or invalid token are also counted

To Reproduce

Run the following code through the preprocessor:

{ 4 5 "some tokens" writeln} .

Notice the missing space after writeln. The preprocessor will accept this code as legal, causing the interpreter to fail undeterministically.

Expected behavior

The above code should be rejected. Curly braces in non-token positions should not be counted.

Platform information

kleinesfilmroellchen commented 4 years ago

Preprocessor.java line 88f is the culprit.

kleinesfilmroellchen commented 4 years ago

Fixed via 1d5e0b659ea839caa91adac08c69d5d1aadc39e3.