metormaon / flue

MIT License
1 stars 0 forks source link

API for accessing and modifying a rule. #1

Closed yossigil closed 3 years ago

yossigil commented 3 years ago

The regular expression in the rule body must be accessible; perhaps not modifiable, but it should be able to create a rule programmatically so that one can develop and run algorithms such as first and follow on the set of rules.

https://web.eecs.umich.edu/~weimerw/2009-4610/reading/FirstFollowLL.pdf

yossigil commented 3 years ago

This API is documented perhaps?

metormaon commented 3 years ago

Not yet. But EBNFTest uses it for FIRST(). Still with a bug, but demonstrating the capability.

The API is in fact a Visitor and a Traverser. I hope it's what you had in mind.

On Fri, 11 Jun 2021 at 20:08 Yossi Gil @.***> wrote:

This API is documented perhaps?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/metormaon/flue-api/issues/1#issuecomment-859722334, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFJ3LLLU2GIBUDXHL44U5TTSI7JJANCNFSM44QYP75A .

yossigil commented 3 years ago

You need only one: a visitor.

You may want to apply something a little more tricky, but useful. A visitor should supply a reduce function. The API should apply this reduce function. A reduce is a function from TxT...xT a tuple of T's to T. The API goes over the tree and applies this function bottom up.

metormaon commented 3 years ago

Do you mean that when the visitor visits a Multinary, it will use the reduce method?

If so, then:

  1. Isn't reduce() merely part of the specific visitor's implementation?
  2. Do you expect the same reduction logic for or, then, andAlso nodes?
  3. Is it even possible with the visitor change we made yesterday? visit() cannot access it's children, nor can it call their visit() directly to get their T's... That's what I initially created a Traverser for...
yossigil commented 3 years ago

The client supplies its own reduce function. The API runs reduce on the tree structure. Not crucial, but nice architecture See here: https://gist.github.com/Ad115/fbee7a7a85935888d383f05b7f99e956

yossigil commented 3 years ago

https://pkg.go.dev/golang.org/x/exp/ebnf

You may check this out for reference