flat assembler
Message board for the users of flat assembler.
Index
> Programming Language Design > FTCBASIC (Fast Tiny Compiled BASIC) Goto page Previous 1, 2 |
Author |
|
geekbasic@gmx.com 02 Mar 2023, 04:11
I have done a small update to FTCBASIC.
I realized that you couldn't define a string with a comma in it due to the parsing using commas as a delimiter. The define var$="," wasn't working, so now you can do the following: Code: define strvar$ = comma, strvar2$ = "some text", strvar3$ = "more text" FTCBASIC also has a new home at www.lucidapogee.com |
|||
02 Mar 2023, 04:11 |
|
geekbasic@gmx.com 03 Mar 2023, 21:31
Never heard of a finite automata before, but I am searching and reading about it. Thanks.
Here's the bit of code that does what I was referring to. Code: CASE "DEFINE", "CONST" LET comma = 1 WHILE comma LET comma = INSTR(parameters$, ",") IF comma THEN LET section$ = LTRIM$(RTRIM$(LEFT$(parameters$, comma - 1))) LET parameters$ = LTRIM$(RTRIM$(RIGHT$(parameters$, LEN(parameters$) - comma))) ELSE LET section$ = parameters$ END IF LET varname$ = LEFT$(section$, INSTR(section$, "=") - 1) LET vardata$ = RIGHT$(section$, LEN(section$) - LEN(varname$) - 1) LET varname$ = RTRIM$(varname$) LET vardata$ = LTRIM$(vardata$) IF RIGHT$(varname$, 1) = "$" THEN LET varname$ = LEFT$(varname$, LEN(varname$) - 1) IF UCASE$(vardata$) = "COMMA" THEN PRINT #3, varname$ + " db 44,0" PRINT #3, "rb 1023" ELSE PRINT #3, varname$ + " db " + vardata$ + ",0" PRINT #3, "rb 1023" END IF ELSEIF LEFT$(UCASE$(varname$),6) = "CONST " THEN LET varname$ = RIGHT$(varname$, LEN(varname$) - 6) FOR constant = 0 TO constants - 1 IF constname$(constant) = "" THEN LET constname$(constant) = varname$ LET constvalue(constant) = VAL(vardata$) EXIT FOR END IF NEXT constant ELSE PRINT #3, varname$ + " dw " + vardata$ END IF WEND Warning, newbie compiler dev talk: COMMA is just a keyword to allow you to define a string as a comma to concatenate, compare, etc with other strings. I didn't take the optimal approach in implementing strings. Just the bare minimum one. In my language, strings more of an experimental bonus feature. I waned to see if I could accomplish basic parsing routines for games with simple text input like interactive fiction. I would love to improve it, but realistically that will not happen anytime soon. My code is as primitive as a couple of cavemen with clubs, but the source is simple to follow. I created my first BASIC interpreter when I was 15. It used simple expressions with 2 operand and 1 operator. Last year, I returned to my old code and wanted to see how much I could improve it. I had to write some kind of expression evaluation routines to make something better. Using my new routines, I created a new interpreter called Craft Basic . It has been my testing ground for language creation. I have been keeping it up to date and think it's pretty cool, but slow due to the lack on tokenization. With the help of this wonderful forum and it's members, I have learned how to create an x86 compiler. Wouldn't have been able to do it without you guys. Having a good community to learn from makes a big difference. Now I am working on a tokenized interpreter. It's super fast. Currently, it's written in QuickBasic, but I will soon port it to Ionic Wind Basic. This time the token translator and token interpreter will be two separate programs so that the interpreter part will likely by under 100kb when finished. This will be a 32 bit Windows program. A source to asm compiler, direct interpreter, and token interpreter. Of course, these are nowhere near the best examples of such things. For better or worse, I have taken a unique approach. I am also trying to rewrite my expression evaluator in C, but while I write parsing functions, I am realizing that it will be more effective to learn more effective routines. This is something that could take me a very long time. |
|||
03 Mar 2023, 21:31 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.