-
Notifications
You must be signed in to change notification settings - Fork 2
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
expr2rulenode
/ string2rulenode
#78
Comments
yes, this would be very useful in general! For example, defining a sketch. I really like that you focused on expression to RuleNode rather than text to RuleNode. We were postponing the addition of this functionality because starting from text is a really tough problem, though we might use some existing libraries for parsing. However, starting from Julia expressions is a much better choice. |
How about: function string2rulenode(str::String, grammar::AbstractGrammar)
expr = Base.remove_linenums!(Meta.parse(str))
return expr2rulenode(expr, grammar)
end works on this single test case at least: julia> string2rulenode("(moveUp(); (moveRight(); grab()))", grammar_robots)
3{9,3{6,11}} |
ag, maybe it is that simple if we rely on Julia parser :) |
Which I think is the only parser that makes sense for now, given that we require the rule to be a valid Julia |
Can you post exactly what you're passing to the function? I think you might be missing a comma. |
This is the stacktrace of the string2rulenode function. It seems to be going wrong in the built-in julia functionality. Especially the
This
|
Oh, then I misunderstood what you were asking for. This will take the string/expression representation and return the |
Ah okay, I also can't seem to get the functionality to work with a function which would be very useful as well. E.g. calling the
With the following stacktrace:
|
I think the correct input, according to your grammar, would be the string "2 * x + 1" |
Ah, that's right. But, even after simplifying the input, it still doesn't seem to work. It still gives the same LoadError.
|
Yes, you're right. Like I said, I'd only tested it with some very specific examples. It looks like it only supports the example I tested so far. Feel free to suggest changes, but this isn't something we'll include right this moment, anyway. |
Since we needed it to create a benchmark, I have created this monster method which does it. I can't say it is 100% bug-free, but I tested it on about 20 different instances and those all worked. Feel free to test it out, and let me know if you find a bug.
Some test code:
|
Relates to the RuleNode programs in the old psb2 branch |
some options to build upon: |
+1 for ParserCombinator. The lack of updates on the project is a little worrisome, and documentation isn't the best, but I just used it to build a little parser for AEON files for the Biodivine boolean network benchmark. |
Closed by #98 |
Given an
Expr
and anAbstractGrammar
, I'd like to get the correspondingRuleNode
.For this grammar
A partial implementation might look like
resulting in the following functionality:
This would be quite useful when testing, for example.
The text was updated successfully, but these errors were encountered: