Post Reply 
C translator for calculator project
05-07-2019, 05:24 PM (This post was last modified: 05-07-2019 07:40 PM by Claudio L..)
Post: #16
RE: C translator for calculator project
I agree with a lot of the opinions given above, and here are my own observations:

* I read above that Keystroke + some structure = RPL, that's true (and there's no shame in that!), and it's not a bad start, translating to keystroke should be quite straightforward.

* C is not the best choice for calculator (typed variables, etc). Other languages work much better as command-line (scripting) languages than C.

* For simplicity (especially if you write your own parser), I'd take a look at BASIC, Lua or micro-python syntax.

* BASIC is easy to code yourself a parser/translator. This would be my first choice to try.

* Lua has a tiny parser that compiles to its own bytecode, and a separate VM that runs the code. You can either run its VM as-is or reimplement the bytecode opcodes in your own keystroke language (since you want a translator, rather than a canned language). I think there's less than 30 different opcodes so it's not too far fetched to implement those opcodes in your own keystroke language. I don't know, however, how the features in your language will play with the features in the parsed language (especially memory management). Both the parser and VM are designed to be easily embedded within applications, so it's quite easy to insert within your own projects (I've personally used it in a couple unfinished/unpublished projects so I can attest to that).

* micropython syntax is more widespread than Lua, but it's a complete environment to run on bare hardware. I'm not so sure how easy it is to extract the parser from there (I'm not too familiar with it other than reading some docs), and I believe it compiles directly to native machine code for various targets (judging from a quick look a the source code). This might make it harder for you to use it as a translator to your own keystroke code.

* A final idea: If you roll your own translator, you might want to also consider using PPL as the higher level language. At least it will make your calcs able to share existing code with the Prime (or at least more easily port).

EDIT: Another "final idea": Take a look at Xerxes calculator benchmark for a nice example of how the same code looks in many, many languages including the ones cited above.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
C translator for calculator project - Dan - 05-06-2019, 05:18 AM
RE: C translator for calculator project - Claudio L. - 05-07-2019 05:24 PM



User(s) browsing this thread: 1 Guest(s)