Commit Graph

29 Commits

Author SHA1 Message Date
Lephe 8d8707f3a9
keyseq: start a feature to print input sequence 2022-01-15 11:48:10 +01:00
Lephe 8c3341d09f
tests: add two more entries to the 2019 contest 2019-10-26 18:35:58 +02:00
Lephe 77404fa61b
lang: realize that WHILE was actually UNTIL 2019-10-26 18:29:58 +02:00
Lephe 32fbcf143a
more atomic committing
* Proper coordinate rounding, as in Arond()
* Forgotten EOL now consumed if found (still optional)
* Convert unit tests images to 1-bit before comparing
* Much better unit testing script
* Add 17 test scripts from the 2019 TI-Planet and Planète Casio contest
  which consisted in reproducing an image with minimum code
2019-10-26 13:51:54 +02:00
Lephe ff6013b603
parser: allow semicolons to finish arguments early
Similarly to how parentheses are omitted at the end of commands, this
change allows them to be omitted at the end of function arguments.
Notice however than this omission is *ambiguous* when the parser does
not know in advance the number of arguments.

  GCD(Ent(x;y -> GCD(Ent(x;y))
              -> GCD(Ent(x);y)

The fx-92 SC+ parser knows the number of arguments for each function,
and will use the second interpretation, because Ent() has one argument
and GCD() has two. This interpreter, however, uses a generic extensible
construction for function calls and cannot decide on this ground. The
current interpretation is the first.
2019-10-26 09:55:59 +02:00
Lephe f1cc4ace40
update atomically (like a bomb)
* Fix angle units for reverse trigonometric functions
* Add a streaming option to capture the output in real-time as a series
  of bitmap images
* Switch to Decimal due to the non-continuity of Ent() breaking
  assumptions about the fidelity of floats. Trigonometry functions are
  still computed as floats.
* Fix the line rendering algorithm for edge cases and add a new test
  line-positive.txt that ensures basic patterns are all correct.
* Use custom rules to generate text representation of decimal numbers as
  to better match the output of the fx-92.
* Improve the test constants.txt to better evaluate this representation.
  The interpreter automatically checks that the representation matches
  the value and fails on error to avoid scratching heads.
* Fix EQUAL not being treated as a relational symbol.
2019-10-25 13:38:10 +02:00
Lephe c52e7ccaa3
lexer: record each constant's representation in the token 2019-10-17 10:33:30 +02:00
Lephe 907c800696
add the theta variable name 2019-10-15 11:25:39 +02:00
Lephe 81a8c58b70
add a README file 2019-10-09 07:09:35 +02:00
Lephe 053c1ebfaf
add exponentation in the bitcode lexer 2019-10-08 22:32:27 +02:00
Lephe 14846e56ae
add functions with multiple parameters 2019-10-08 21:20:08 +02:00
Lephe afb0511ea0
allow more flexible constant specifications 2019-10-06 11:51:02 +02:00
Lephe 9bf03c52be
allow <sign><function> atoms 2019-10-06 10:57:58 +02:00
Lephe 7db38aac06
add basic unit tests
Windows can't be hidden yet because texture rendering seems to fail in
this case. This will have to be investigated later.
2019-10-06 02:08:58 +02:00
Lephe 69b5b52fdd
structural update: move files to a subfolder
Also update the documentation of supported tokens and features for more
clarity.
2019-10-06 01:34:42 +02:00
Lephe 2c7287338c
use proper line rendering
There are some edge cases to Bresenham's line drawing algorithm with
cumul=dx. The fx-92 SC+ clearly checks cumul>dx, but for dx=1 and dy=1
this results in a horizontal line.

Apparently dx=dy is the only case where the fx-92 SC+ behaves
differently than cumul>dx, as seen with dx=5 dy=4 (causes cumul=dx after
2 iterations but does not trigger the condition).

Also allow the program to be interrupted with Escape while paused.
2019-10-06 00:06:04 +02:00
Lephe ab057abddd
add the wait command 2019-10-05 11:55:06 +02:00
Lephenixnoir 1e7ca230d4 Merge branch 'master' of Pavel/fx92-interpreter into master 2019-10-05 11:54:53 +02:00
Pavel Demin ff1cf81380 reimplement enum.auto() for compatibility with older python 3 versions 2019-10-05 11:46:05 +02:00
Pavel Demin 3f5db406eb improve compatibility with older python 3 versions 2019-10-05 11:26:43 +02:00
Lephe a983faedeb
add relations, and most functions
This change adds a [cond] grammar symbol corresponding to binary
relations in IF, IFELSE and WHILE conditions. It also adds support for
unary functions with parenthesis syntax. Other functions will need
specific rules depending on their operator precedence level.

Also adds the Window.save() function that implements the --save option
to save the output of the program into a bitmap file. This will be used
to perform automated unit tests.
2019-10-04 12:44:27 +02:00
Lephe 0e9a2ee944
use true window size 2019-10-02 07:56:58 +02:00
Lephe 3d8dcdd989
add command-line options and a text lexer
This change lays the ground for automated unit tests. It adds
command-line options to select the input language format between URL
(hexa text) and plain text, change a few output settings, and redirect
graphical output to an image.

A text lexer has also been added so that unit tests and new programs can
be written in an English-like syntax instead of raw hexadecimal.
2019-10-02 07:18:29 +02:00
Lephe 0189d7f372
fix most remaining bugs 2019-10-02 07:17:46 +02:00
Lephe eaaee18bc7
use the proprer line rendering algorithm
The proper Bresenham setup used by the fx-92 SC+.
2019-10-01 18:06:05 +02:00
Lephe cd2936c582
add a first interpreter
Note that there are still bugs and the output is really not what it
should be. Will fix that with unit tests ASAP.
2019-10-01 18:05:22 +02:00
Lephe 8269ab3f19
add SDL2 rendering with a simple test 2019-10-01 13:40:52 +02:00
Lephe f08f613a17
improvements on AST shape and printing 2019-10-01 07:04:02 +02:00
Lephe 6151144d0a
initial commit: most of the lexing and parsing work
The program is currently able to lex most useful tokens, and parse
constructs associated with them on simple examples.

Unit tests are still missing to formally ensure everything's right.
2019-09-30 11:29:05 +02:00