-
Notifications
You must be signed in to change notification settings - Fork 372
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
Fully functional reader macros #722
Comments
Basically, thats what we have been thinking about. But we ain't really sure what to do. Hack rply into a suitable form? Replace everything (again)? On 12/15/2014 02:52 AM, Bogdan Opanchuk wrote:
|
Based on my very limited understanding of how parsing works, I don't think you can represent full Lisp reader with a lexer-parser pair. So, no amount of tinkering with Of the two solutions I mentioned, I'd prefer the latter one: keep What also slightly worries me is that a full reader reads input stream character by character, as opposed to |
I have a branch sitting around that has an almost complete parser-combinator for Hy written in Hy… it will just need some love to update it with the recent changes. Once we have an actual reader (and not a parser-generator) implementing reader-macros, while not trivial, is not far fetched.
|
Bumping this from the grave; I was fooling around and wrote a fairly straightforward reader/parser that reads one character at a time, but my initial prototype seems to actually run a bit faster than the current If there's interest, I can implement the full grammar in this thing and get a PR going; having this would allow us to:
*Well-bracketed f-strings as in: |
That definitely sounds interesting, although it would probably be better to use |
I tried a parser in The custom parser still beats all of these in terms of performance, while also easily allowing for a modifiable reader table for reader macros. *My funcparserlib implementation is parsing by character instead of tokenizing, since early tokenization is what blocks us from better f-strings, custom readers, etc Results from parsing a ~3100 line file, min of 25 runs reported
|
hot dang scauligi this sounds really cool! do you have a fork we can look at? |
Currently Hy has some limited support of reader macros (quote,
#
etc). Is it planned (or even wanted) to add full support of reader macros similar to CL'sset-macro-character
? I think it will require either replacing the current lexer+parser pair with a custom reader in Python, or, alternatively, leaving the lexer+parser as the first stage that compiles the actual reader written in Hy.The text was updated successfully, but these errors were encountered: