kosen13s / tiny

A tiny programming language to improve kosen13s' skills
MIT License
4 stars 0 forks source link

Rethink about tokens' data types #9

Closed Roadagain closed 7 years ago

Roadagain commented 7 years ago

@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.

Iruyan-Zak commented 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.

Iruyan-Zak commented 7 years ago

Probably you think that, some parsers should return a expression. So I'm planning some data types.

So, my questions are

  1. Does my plan look cool?
  2. If so, how should I name XXX?
Roadagain commented 7 years ago

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".

Roadagain commented 7 years ago

i've thought '+' should be in prefixOperator cuz tiny should operate "+2" as 2.

i need your opinion.

Iruyan-Zak commented 7 years ago

Mathematically, it is better to add +, but I think it is unnecessary. Have you ever used unary + operator in any programming languages?

Roadagain commented 7 years ago

never... it is really unnecessary lol

Iruyan-Zak commented 7 years ago

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.

Iruyan-Zak commented 7 years ago

Can I create PR?

Roadagain commented 7 years ago

yes, i will merge it.

Roadagain commented 7 years ago

close via dfc3313