Lartu / ldpl

COBOL-like programming language that compiles to C++. With serious dinosaurs with neckties and briefcases 🦕💼
https://www.ldpl-lang.org/
Apache License 2.0
158 stars 24 forks source link

Octal numerals #83

Closed Lartu closed 5 years ago

Lartu commented 5 years ago

When in LDPL you execute the statement

DISPLAY 0123

the value 83 is printed instead of 123. One would expect 123 to be printed, but this other number is printed instead because C++ asumes numerals that start with 0 (even 0 itself) to be encoded in octal base.

The same happens with vector accesses, for example if you store 1 in vector:0012, if you read vector:12 you'll find a 0, for the index that was accessed is not 12 but octal 12.

This should be fixed by checking if numerals have leading 0s and removing them (except, of course, if they are followed by a . and decimals).

Lartu commented 5 years ago

Fixed in ad0b77e538058d61b8af844a2026cc96d4b09218.