Add Nim to TranslatorSpec and fix various errors found thanks to that #292
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR includes #291, because Nim octal escapes will consume all possible digits, so string with escape sequence followed by digit will be treated incorrectly. Hex escape form does not suffer from such problem. Instead of overriding logic in Nim I decided to make a Hex representation as default because most languages have it. If you do not agree, please tell me and I change that.
This PR fixes the following bugs found during testing:
not
keyword and require a space after it, so~777
not become identifiernot777
. Lua was suffer from the same problem.if ...: ... else: ...
expression), casts and string concatenation (&
operator)div
and/
accordingly. Attempt to usediv
with float numbers lead to a compilation error. This was fixed in the same way as Python does that by inspecting deduced types of an arguments.first
,.last
,.to_i
,.substring
methods called on expressions does not wrap them into parenthesis, so(1 + 2).to_i
becomes1 + 2.to_i
I checked all generated expressions on https://play.nim-lang.org/ so I assume that their all are correct.
I also notice a strange thing. Nim has an extendable
$
operator to converting everything to a string. However,.to_s
implementation generatesintToStr(int(value))
which means conversion to integer, then conversion to string. It seems that it is possible to replace that stuff with$
operator stuff, but maybe there are some nuances. @sealmove, you a created Nim implementation, can you check, is that possible?