Comments (9)
I'd like to see an example of some of the syntax you're referring to first.
from participle.
Unfortunately, I can't give concrete examples, as the project isn't open source (yet). Without giving too much away, consider a heredoc-like syntax where the A) the inner language is not expressible as a regular grammar, and B) the heredoc terminator is only accepted if it is located in certain points within the sub-language, otherwise, it consumed as part of the sub-language, and there must be another terminator located elsewhere. As a result, once the heredoc starts, there has to be custom logic to figure out where it ends, and then to validate that what's in between is even allowable, and if not, lexing (not parsing) terminates. If it weren't for point (B), a .*
with a backreference could probably capture it, but without knowing if that opaque string is valid or not means it can't be correctly checked as a token or not, and capturing too early may result in an invalid lex.
from participle.
I'm not necessarily opposed to the stateful lexer being extensible, but I won't accept a backward breaking change. From briefly looking at the your code, I would suggest looking at extending Action
to support your use case.
That said, without any concrete examples/tests showing use-cases, I won't accept it either.
from participle.
Of course. Like I mentioned, this was a quick "What if?", and any actual PR I would submit would be backward compatible, with documentation, test coverage, and no regressions.
Given that none of the methods of Action are exported, I'm not sure I follow you suggestion, and even looking at the unexported method, I don't see a simple way to have it generate additional tokens, but perhaps I misunderstand. Are you suggesting to export Action's method, and modify it to optionally return tokens as well as modify the state?
from participle.
I'm proposing you extend the private Action
interface to support your requirements, or add another optional interface similar to how RulesActions
works. Then expose that functionality via a public function similar to the existing ones, such as Pop
, etc.
from participle.
Ah, and rules must also be serialisable to JSON.
from participle.
Before you do anything, you should extract a representative example (obfuscated if necessary) and include it in this issue.
And perhaps an example of how you would use this proposed new functionality to lex it.
from participle.
On the serialization note, is that just for diagnostic purposes, or does it need to be able to round-trip? My goal is to be able to inject an arbitrary function to execute, like in the linked fork, which obviously wouldn't be able to round-trip without having some sort of global lookup table to register functions to on initialization.
from participle.
It needs to be able to round-trip, but I think for this case it could just return an error.
from participle.
Related Issues (20)
- Missing wildcard HOT 2
- Unquote function panics when an escape character exists in string. HOT 4
- Parser being greedy HOT 3
- Dependency Dashboard
- Action Required: Fix Renovate Configuration
- Panic when stateful lexer's non-Root rule has optional group but captures nothing HOT 3
- Need advice: Wrong branch is picked on non-trivial match HOT 1
- too many iterations panic HOT 1
- Adding a custom lexer rule without overriding current rules.
- Error recovery ideas HOT 4
- Request for help (aka so near and yet so far).
- Railroad diagram command HOT 6
- Question: Are participle.Parser instances thread-safe? HOT 1
- Handling Booleans bug HOT 3
- PAnic vs return nil in validate function HOT 2
- Issue with a nested structure HOT 1
- JSON parser support
- example not working? HOT 2
- Very weird bug using otherwise OK parsers in Union HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from participle.