QMCL Interpreter

Started by iWasAdam, June 09, 2024, 12:56:08

Previous topic - Next topic


Yep, that could be done, but I decided not to do it as it would require pre-parsing and separation.

I's simpler to use ().

In a lot of respects, it's more in common with machine code. you only have 2 inputs and 1 output. stuff that is longer need special handling.
my previous languages used no multiple maths, so this is much better - lol


Okeydokey Then. 

Im Sure you have good reasons for this concept :))

Are you going tobe showing any snipets of code as a tutorial or something on how you approach Scanning and Tokenising into the tree AST concept? As i woud love to see some ideas on how it is approached!?

Kind Regards Baggey 
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 24GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!


hmmm. Would you believe I dont actually use any AST trees?

I'm dealing with it all in small bites. So the first thing was getting the text in and the next being processing a code line.

Here's how I am approaching it:
1. first you take a string and tokenize it
2. parse the tokens and do an initial syntax check

tokenizing is not too hard, clear inputToken:string, and go through the input string character by character. if there is a space ignore it, something interesting (_,+, 1234,( ), etc process the inputToken and clear it. Otherwise add the current char to the input token. I can post code for this if you want??

processing the inputToken is reasonaably simple. you check the inputToken against keywords, system variables, variables and numbers. this will give you the basic keyword, identifiers, variables, etc
NOTE. I'm not doing a lot of heavy syntax checking, just checking that everything is valid.

I do the tokenizing as you enter each line.


When running a program line:
I take the first token and check for a keyword
depending on the keyword, I then get possible data. this means checking the variables and evaluating math...

In essence this is much more like machine code:
so with the line

Get a operand/keyword x=
get data. E.G. get value of x, + operator, 1 number
eval data if needed (math stuff). E.G. (x+1)
execute it. x=eval

This is the current stage I'm at. next stage is to implement some quick commands. After that it will be looking at 'if' statements, loops, etc