Closed hildjj closed 6 months ago
I agree with you about passing a state object around. That might be cleaner, but probably a hair slower.
The other thing I don't like is setting up all of the constants each time a remote rule runs. A good JS runtime will probably make that not a big problem, but it's still hard to read.
I'd like to get the interface right here, we can always optimize the generated code better later. I'm going to land a few more changes on top of this before merging to see what happens.
OK, I think this is pretty close -- it seems to work. I think this gets everything important in #292, plus several more things. @Mingun would you like me to use opcode 43 instead of 41?
From the PR description:
Return an object that has the needed
The needed what?
From the PR description:
Return an object that has the needed
The needed what?
sorry. Has the needed properties for parsing to continue on with the appropriate state.
This still needs docs.
Managed to import a rule from a package hosted on GitHub: https://github.com/frostburn/peggy-string-concat/blob/main/index.peggy
Managed to import a rule from a package hosted on GitHub: https://github.com/frostburn/peggy-string-concat/blob/main/index.peggy
Did you check in those changes to peggy-string-concat? I was expecting to see an import
statement at the top of https://github.com/frostburn/peggy-string-concat/blob/main/index.peggy which called to a compiled .js version of peggy-string.
Managed to import a rule from a package hosted on GitHub: https://github.com/frostburn/peggy-string-concat/blob/main/index.peggy
Did you check in those changes to peggy-string-concat? I was expecting to see an
import
statement at the top of https://github.com/frostburn/peggy-string-concat/blob/main/index.peggy which called to a compiled .js version of peggy-string.
I'm not sure what you're asking. I changed my peggy dependencies in both repositories to hildjj:library-mode
. In peggy-string
there's now a module.exports
at the end of the compiled file and in peggy-string-concat
there's now var peg$import0 = require("peggy-string");
at the start of the compiled file.
I'm not sure what you're asking.
I'm not either. After looking again and trying your code, it works great, exactly as expected. I appreciate your work!
This is an internal-only interface for calling into rules in other grammars.
This is a prerequisite for being able to import rules in grammars. The idea is:
import * as foo from "./foo.js"
will be possibleparse
peg$parseMyLibrary_Foo()
will callpeg$callLibrary(MyLibrary, "foo")
I've got the start of the code that processes imports in another branch, but I wanted to have a discussion about this part first.