-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TOP #45
Comments
Oh good grief! I can't believe I'm today years old and I learn |
The I don't think there are any other pseudo-tokens to worry about at least. I've long wondered (not very actively admittedly - it doesn't often keep me awake at night) why there isn't a token for Golf tip: If you want to use |
So good :) thanks @ojwb |
Well, this one's a tricky one and no mistaking. The tokeniser is much too simple to know when to colesce the tokens: it's necessarily not a full parser (and it's based off what the the underlying editor provides us). Looks like this would need us to "know" we're in a FOR and we're expecting |
Note for self: this test needs to pass: it("should handle TOP properly", () => {
// See #45
checkTokens(
["F.P=TOP TOP"],
[
{offset: 0, type: "keyword"}, // FOR
{offset: 2, type: "variable"}, // P
{offset: 3, type: "operator"}, // =
{offset: 4, type: "keyword"}, // = TOP
{offset: 5, type: "white"}, // space
{offset: 6, type: "keyword"}, // TO
{offset: 8, type: "variable"}, // P
]
);
}); |
I've wondered if the editor should use the tokenised form as its internal representation, though if the syntax highlighting can only change the styling of the text we couldn't just make the text be the tokenised BASIC as we'd need to show something different to the text (e.g. display "TO" for character That wouldn't directly solve the Perhaps there's a neat trick to get this right though - I'll see if I can come up with anything. |
We are stuck with whatever Monaco does; its internal represntation is text.
So making it tokens doesn't help unfortunately. We are limited to whatever
it supports, and I don't know quite how the user experience would be trying
to edit a token as text.
Remember how the Spectrum toekn-based input worked...was super confusing
:). Not saying your suggesting that but storing tokens but editing
characters sounds tricky even if the editor allowed it.
…On Sun, Dec 13, 2020, 18:04 Olly Betts ***@***.***> wrote:
I've wondered if the editor should use the tokenised form as its internal
representation, though if the syntax highlighting can only change the
styling of the text we couldn't just make the text be the tokenised BASIC
as we'd need to show something different to the text (e.g. display "TO" for
character \xB8). So the whole idea might be a non-starter.
That wouldn't directly solve the TOP vs TO+P issue, but I think would
make it simpler to determine if we're in a place where TOP is TO+P.
Perhaps there's a neat trick to get this right though - I'll see if I can
come up with anything.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#45 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE2Y5NHNTSGJIGIBST6PGLSUVI77ANCNFSM4ULCM6BA>
.
|
Some of the offsets there are ... offset - they should be:
I had a little look - it seems it would need to be done by adding more states to the highlighting, but doing it properly seems to require doing the runtime expression parsing which BASIC presumably does when running the code since after the
After Perhaps we can cheat and in a |
TOP
is a bit of an odd-ball keyword in that it doesn't actually have its own token but is actually tokenised as aTO
token followed by a letterP
.The syntax highlighting doesn't seem to know about this quirk, e.g. this actually colours the
P
brown instead of blue:You can't just colour any
P
afterTO
blue though, consider:There the first
TOP
isTOP
, but the secondTOP
is actuallyTO P
.The text was updated successfully, but these errors were encountered: