ulisp-esp
ulisp-esp copied to clipboard
suggestion to simplify gfuns
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.