Thanks for the [=[ suggestion, it works just as well!
 
22.11.2020, 19:17, "John Benediktsson" <mrj...@gmail.com>:
Yes, here's how (currently depending on the implementation behavior, but this has worked for a long time).
 
For example, in the urls.private vocabulary there's a parser for URLs, and you can get the peg parser from an EBNF: word.
 
    \ parse-url "ebnf-parser" word-prop main of
 
Most of our EBNF: words have been converted to use multiline strings, which avoid the escaping issue if you want to do the same:
 
    EBNF-PARSER: word [=[ ... EBNF string ... ]=]
 
I've gone back and forth with triple-quote strings.  They exist in some languages, but they also make parsing single quote strings a bit more difficult.  We removed them while working on some new parser techniques, and the multilline vocabulary has a few other options like the example above.  If people think we really should have them, we could revisit it.
 
Best,
John.
 
 
On Sun, Nov 22, 2020 at 1:44 AM Alexander Ilin <ajs...@yandex.ru> wrote:
Hello!

  I'd like to use the peg.search vocab, and for that I need to pass it a parser.
  Most of the parsing words in peg.ebnf produce either a quotation that is immediately called inline (EBNF[[), or produce a word that calls a parser hidden inside it (EBNF:).
  There are only two ways to pass a parser to peg.search:search: construct it from words without using the EBNF syntax, or by using the undocumented EBNF-PARSER: word.

  I managed to figure out how the EBNF-PARSER: works, and the unfortunate thing about it is that the syntax is the following:

EBNF-PARSER: word "...EBNF string..."

  The word will be what we need: ( -- parser ).
  The unfortunate part is that it's very annoying having to escape all the double quotes in the "EBNF string".

  So, now I have two questions.
  1. Is it possible to convert a word defined with EBNF: into a word returning a parser, or to somehow extract the parser from inside it? Is there maybe an undocumented word that could help with that, like by making a wrapper?
  2. Is it possible to return the """ (triple double quoted) string syntax, which doesn't require escaping single double quotes inside them?

---=====---
 Александр



_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk
,,

_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

 
 
---=====---
Александр
 
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to