Closed Roadagain closed 7 years ago
i guess constructing unary operators as Unary token (Tree token)
and renaming Node
to Binary
.
then it changes like this:
data Tree token = Leaf token |
Binary (Tree token) token (Tree token) |
Unary token (Tree token)
if we use this construction, should we rename Leaf
too?
@Roadagain
- is it cool?
agree to your idea completely.
- how should we configure prefix and postfix operators (include unary operators)?
Your last comment is better. In my head, the order between prefix and suffix operators is suffix priority.
- should we rename
Leaf
too?
I think it's no problem naming.
Because Binary
is regarded as an omission of "binary tree" and Unary
too, so Leaf
means "the leaf of a binary or unary tree."
Further, Tree
is general naming and usable generally, so Leaf
should be also general one. (or rename Tree
.)
constructing trees has been done by a2a266d, but it doesn't seem beautiful.
i have two ideas:
Tree
(with StateT
?)if you have something else, write here.
bugfix has been done, then i wish to implement prioritized construct.
i hope to add a new field holds priority (maybe Int
) to Token
.
Cannot you deal with it with an associated array (operator => priority)?
well... i will try it.
succeeded. is there any job not-implemented?
Great job. roll
function looks cool solution for me!!!
btw, I was surprised by returning an unary tree from binary
function...
If you think it is a no important problem, please create PR now.
i've forgotten it is implemented to make easier to test. i will add an integrated function to construct syntax trees.
i guess no functions can surprise u already. can i create pull-req?
i guess the trees will be like this constructed by values and binary operators.
i have 2 questions: