IRC channel logs

2024-09-05.log

back to list of logs

<ekaitz>hi, i have a PEG grammar that uses underscores in the nonterminals
<ekaitz>that's not compatible with guile's PEG parser
<ekaitz>is there any reason not to add _ in the nonterminals?
<ekaitz>also peg-string-compile is documented but not exported :)
<mwette>ekaitz: at some point `_' became syntax in Guile. It's not in 2.2. I don't know where it comes from.
<ekaitz>hmm
<dpk>that shouldn’t preclude rebinding it (though you might have to disable importing it)
<ekaitz>dpk: i don't understand what you mean
<dpk>‘_’ is just a normal identifier like any other
<dpk>it might be an error if you try to define it at the top-level of a library or program after having imported it from another library (such as (guile) or (rnrs (6)) or whatever)
<dpk>but you should be able to exclude it individually from the import set
<ekaitz>oh yes
<ekaitz>that's why i don't understand why the PEG parser does not allow _ in identifiers
<ekaitz>it doesn't even allow this_identifier
<ekaitz>for terminals
<dpk>oh, it’s a problem with the string syntax for PEGs in (ice-9 peg) ?
<ekaitz>yes
<dpk>ahhh
<ekaitz>it only allows [A-Za-z-]
<ekaitz>or whatever that is
<dpk>i thought you had a nonterminal called _ defined in the string syntax, and it was erroring because it was trying to redefine _
<ekaitz>i just added the _ to the regexp and it just works
<ekaitz>but i had to make a new module on my own
<ekaitz>does it make any sense to allow the _ in the peg parser strings directly? should I make a patch with this?
<ekaitz>i guess they should have a similar syntax to scheme symbols, as they are going to be defined in the current scope
<ekaitz>and symbols support _
<lilyp>I'm not sure why you'd want "_" to be allowed in the PEG parser – what's the rationale?
<lilyp>sym
<ekaitz>lilyp: just compatibility with some other parser tools
<lilyp>symbols also allow *%&
<lilyp>even space if you know how to type them ;)
<ekaitz>yes, i know
<ekaitz>we could add that too
<lilyp>my point was rather that PEG ids could be a subset of Scheme symbols
<ekaitz>yeah, of course
<ekaitz>what I meant is adding _ would not be a superset of the scheme symbol syntax
<ekaitz>but yes, they can stay simpler
<ekaitz>i asked if there was any reason for it
<ekaitz>does the peg string support escape sequences?
<ekaitz>i don't find anything like that
<lilyp>I don't think so – maybe the Scheme API has some
<ekaitz>ugh this is going to be a little bit harder than I expected
<lilyp>for the underline: I think funny characters shouldn't show up in the peg due to possible ambiguities
<lilyp>like a* vs a*
<ekaitz>and a_token <- ...
<ekaitz>?
<weary-traveler>peg as in parsing expression grammar?