Visual PARSE on the Web... has arrived!

It's only the beginning... but the potential is pretty tremendous.

cc: parsing innovators @rgchris, @Brett

image


(EDIT opens a new editor. EPARSE applies the parse rule to the last selected editor, with the usermode addition of a combinator MARK)


  • A Fantastic Case Study of Usermode UPARSE customization - It's just the MARK combinator added in, and it even utilizes the same rollback mechanics that COLLECT uses. So if you mark something during a rule and that rule ultimately fails, the mark rolls back too!

    • ...of course it wouldn't be difficult to make a combinator that did it the easier way and not roll it back...

    • but there are all sorts of web-interactive combinators you might imagine...go ahead and imagine some! :rainbow: :unicorn:

  • REORGANIZABLE TABS - I've built and integrated Golden Layout, but the ReplPad still is a standalone component that can live completely on its own...with a lighter footprint.

  • Integration with Codemirror 6 - We're ahead of the curve on this; it's a very new modularized thing, which has an amount of configurability that should be very enabling.

    • ...and again, there's nothing particularly tying the ReplPad to this editor. None of the JS or CSS for it are loaded until you type EDIT, and we could integrate with other options.
5 Likes

Fantastic job! Thanks Brian!

1 Like

What does it do to

edit "duck duck goose goose wolf chicken duck goose"

uparse [some ["duck" | mark "goose" | "chicken" | "turkey" | space ]]

?

eparse starts uparse on ed-text (and does some magic besides).

[# furthest pending]: uparse/combinators ed-text rules eparse-combinators

sooo ...

do ed-text

DOes the current editor text.

Editor Text:

function []["yay"]

then in the console:

>> a: do ed-text
== #[action! {a} []]

>> a
== "yay"

Works on the visible editor, if you have several tabbed editors, if the editors are in distinct "golden" windows it uses the last opened editor, I think.

1 Like

<dreaming>
now, if

edit source eparse

worked ...
</dreaming>

@iArnold
It errors on a missing rules argument.

If you meant eparse ... it stops at wolf and rolls back, so it removes the marks again and returns null.

with

eparse [mark some ["duck" | "goose" | "chicken" | "turkey" | space ] to <end>]

you get a line showing how far the parse got.

1 Like

Good digging, glad you looked! Though I've gone over the source a little (fixed some broken bits) and pushed it as separate commits to make clear what came in what step.

What's worth showing is that EPARSE itself is a small extension, that is very much not "cooked in". And that we could have little .reb files with .js that add functionality piecewise much like it:

Add EPARSE Parsing Demo Integrating w/CodeMirror ยท hostilefork/replpad-js@8fd981d ยท GitHub

If you could do a git clone of the ReplPad and manage to run a local instance, that would be great to check that everything is committed correctly. And it would mean you could hack on it some. :slight_smile:

You might find some feature inspiration in the CodeMirror 6 examples:

CodeMirror Examples

They are not especially friendly to not having a "compile step". Both Golden Layouts 2 and CodeMirror 6 have moved away from shipping as a .js file you load with a <script> tag in any page... and instead that you have to install the package as part of an NPM buildout of your website... where the expectation is that you compile the site as a whole.

The majority of the work in getting things going was figuring out how to work around that--because I envision loading just what you need, and potentially loading things not anticipated by the site. So I packed up the codemirror pieces: [state.js, view.js, commands.js, language.js] as individual pieces that had their node.js dependencies rolled into them, but were still using each other as separate dependencies. You can get a functional editor with just state and view, and I'm curious how much functionality can be built on top of that with Ren-C bones vs. being all JavaScript.

1 Like