Closed Roadagain closed 7 years ago
OK. Then I change the definition of Parser
to polymorphic.
And then I define a type named Token
, which will be the part of the return type of naturalNumber
and more.
Probably you think that, some parsers should return a expression. So I'm planning some data types.
Expression
] a Term
or a binary tree of ones whose node is a binary operator which includes multiply operator *
.Term
] a XXX
and a list of unary operators optionally.XXX
] an identifier, a literal, or a parenthesized Expression
. This means "can become Expression
without other tokens."So, my questions are
XXX
?it looks cool and great.
In "Progamming in Haskell", XXX
is called as factor
.
if it is needed, i will show you published sources in "Programming in Haskell".
i've thought '+'
should be in prefixOperator
cuz tiny should operate "+2"
as 2
.
i need your opinion.
Mathematically, it is better to add +
, but I think
it is unnecessary.
Have you ever used unary +
operator in any programming languages?
never... it is really unnecessary lol
In JavaScript, +true
has a meaning to cast boolean to int as a kind of hack.
But it is better than being ready for hacking to support such needs with honesty way.
Can I create PR?
yes, i will merge it.
close via dfc3313
@Iruyan-Zak has implemented parsers but token data is returned as string now. i and he talk on slack we should return in another way.
so rethink about tokens' data types.