ulisp-esp icon indicating copy to clipboard operation
ulisp-esp copied to clipboard

suggestion to simplify gfuns

Open dragoncoder047 opened this issue 1 year ago • 20 comments

I was looking at the code and and noticed that all of the gfun_t's (at least the ones it is common to (read) from) have this block of code:

if (LastChar) {
    char temp = LastChar;
    LastChar = 0;
    return temp;
}

I implemented my own gfun_t to read hard-coded data on startup and noticed that it caused reader errors when I commented out the above block in the gfun. (So, I'm guessing your parser would be classified as LL(1).)

To eliminate the need to include this block in each and every gfun_t, why not replace it with something like this to "wrap" an arbitrary gfun:

int mygetch (gfun_t g) {
    if (LastChar) {
        char temp = LastChar;
        LastChar = 0;
        return temp;
    }
    return g();
}

That way, it would allow you to read from any available gfun, including I2C and SPI (which currently don't include the LastChar lookahead-enable block). Then you could read uLisp code off a raw SPI or I2C flash chip.

dragoncoder047 avatar Apr 02 '23 16:04 dragoncoder047