Skip to content
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

Visualizer: Show a useful definition for inherited primitive rules #57

Open
pdubroy opened this issue Mar 9, 2016 · 6 comments
Open

Comments

@pdubroy
Copy link
Contributor

pdubroy commented Mar 9, 2016

In the grammar view, we now show the definition of inherited rules, e.g. ListOf, lower, etc. For rules that are parsed from a grammar, we show the original source, but for primitive rules (e.g. any) we should figure out something useful to show. Maybe something like any = (primitive rule with arity 1).

@mroeder
Copy link
Contributor

mroeder commented Mar 10, 2016

Which are these primitive rules? Is there a list so we can "brainstorm" here a bit?
I feel reminded of what Regex101 offers here:

screen shot 2016-03-10 at 2 50 24 pm

screen shot 2016-03-10 at 2 50 15 pm

So any could be something like Any single character plus a phrase for object matching.

@alexwarth
Copy link

The primitive rules are all in the ProtoBuiltInRules grammar, which is the
supergrammar of BuiltInRules (which every grammar in "userland" inherits
from, at least transitively).

You can find ProtoBuiltInRules in src/Grammar.js.

On Thu, Mar 10, 2016 at 2:52 PM, mroeder notifications@github.com wrote:

Which are these primitive rules? Is there a list so we can "brainstorm"
here a bit?
I feel reminded of what Regex101 offers here:

[image: screen shot 2016-03-10 at 2 50 24 pm]
https://cloud.githubusercontent.com/assets/160313/13687343/85917490-e6cf-11e5-8ae7-9f999b804b98.png

[image: screen shot 2016-03-10 at 2 50 15 pm]
https://cloud.githubusercontent.com/assets/160313/13687338/7cf0d0ba-e6cf-11e5-8dce-e7f8657cae96.png

So any could be something like Any single character plus a phrase for
object matching.


Reply to this email directly or view it on GitHub
https://github.com/cdglabs/ohm/issues/74#issuecomment-195086541.

@mroeder
Copy link
Contributor

mroeder commented Mar 11, 2016

https://github.com/cdglabs/ohm/blob/master/src/Grammar.js#L286
... and they already come with some explanation:

any: any object
end: end of input
space: a space -> Range('\x00', ' ')
spaces: space*
lower: a lowercase letter -> UnicodeChar('Ll')
upper: an uppercase letter -> UnicodeChar('Lu')
unicodeLtmo: -> UnicodeChar('Ltmo'), union of Lt (titlecase), Lm (modifier), and Lo (other)
Boolean: -> TypeCheck('boolean')
Number: -> TypeCheck('number')
String: -> TypeCheck('string')

@pdubroy
Copy link
Contributor Author

pdubroy commented Mar 11, 2016

Yes, I'm just not sure that's all you need to know -- the arity is necessary if you are going to write a semantic action for that rule. Also, TypeCheck and UnicodeChar are not really public things, so I don't think we should be showing them in the UI.

Maybe we should show something like:

lower (a lowercase letter) = /* a primitive rule with arity 1 */

@alexwarth
Copy link

FWIW, I think all of the primitive rules have arity 1.

On Fri, Mar 11, 2016 at 10:53 AM, Patrick Dubroy notifications@github.com
wrote:

Yes, I'm just not sure that's all you need to know -- the arity is
necessary if you are going to write a semantic action for that rule. Also,
TypeCheck and UnicodeChar are not really public things, so I don't think
we should be showing them in the UI.

Maybe we should show something like:

`lower (a lowercase letter) = /* a primitive rule with arity 1 */


Reply to this email directly or view it on GitHub
https://github.com/cdglabs/ohm/issues/74#issuecomment-195496646.

@pdubroy
Copy link
Contributor Author

pdubroy commented Mar 11, 2016

Good point.

@pdubroy pdubroy transferred this issue from ohmjs/ohm Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants