question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exit a state at end of line

See original GitHub issue

The language I’m writing for has “to end of line” sub languages. I use a “first token of the line” root state to dispatch to sub-states, but then am having trouble exiting those sub states at end of line. It seems there’s a design feature of Monaco to not match @eos as a token. Can anyone suggest a mechanism by which I can achieve this?

In this case, a * at the beginning of a statement (either start of line, or after a :), is a “to end of line” keyword. But within a line it’s a multiply.

This * should be tokenised as an operator

PRINT 10 * 20

This needs to be a single line keyword:

*FX200, 3

This shows both, the PRINT bit is one, the *FX part needs to be to end of line.

PRINT 2*3:*FX200, 3

Example of me trying to do this: https://github.com/mattgodbolt/owlet-editor/commit/b5ce47c63389891866eccf315ead7422b9890af7

The approach is to go to a “submode” once the first token is determined not to be a star (or a REM or other). A colon exits the submode, and ideally I’d like “end of line” to do the same. Any thoughts? THanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
CareyJWilliamscommented, Dec 30, 2020

[/.$/, 'keyword', '@pop'] is roughly where I was going with the EOS cases. The difficulty is that it doesn’t scale well, for example when you’re not sure what the last token in the line might be.

E.g. if you have a function/command that takes an arbitrary number of parameters of any type: call myfunc: true "string" 1234 false "another string"

In this case you’d need to have at least three @\pop cases, one for each type, perhaps more if you could pass expressions, objects or functions etc.

I don’t currently see any way around that (without resorting to the SOL detection I mentioned before). I don’t know if you could match on a linebreak? I didn’t have much luck doing so, but I won’t pretend to have tried for very long.

1reaction
CareyJWilliamscommented, Dec 30, 2020

Indeed, brilliant! Thank you so much.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exit state at end of line in ace editor syntax highlighter
The main problem is that at the end of line ace allows only one state transition ...
Read more >
Freeway Entrance and Exit Markings Long Descriptions
Arrows indicate that the direction of travel is from the bottom of the figure to the top. A solid yellow line is to...
Read more >
How to exit (quit) Linux vi editor with or without saving ...
First how to launch vim. From the command prompt: change to path where file is located with “cd”. vi filename. This will edit...
Read more >
Exit numbers in the United States - Wikipedia
Exit numbers in the United States are assigned to freeway junctions, and are usually ... Exit numbers typically reset at political borders such...
Read more >
New York State Thruway Interchange/Exit Listing with Mileposts
Ardsley - NY Route 9A (No Southbound Exit) ................ 7.58 ... END. New Jersey State Line - Garden State Parkway ................ 2.40.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found