aragon / radspec

🤘 Radspec is a safe interpreter for Ethereum's NatSpec
MIT License
142 stars 36 forks source link

Add power operator (^) #18

Closed onbjerg closed 6 years ago

onbjerg commented 6 years ago

Instead of having to write 10^18 manually (10 with 18 zeroes), it would be nice if we could just write 10^18.

Acceptance criteria

status-open-bounty commented 6 years ago

Balance: 0.000000 ETH Tokens: ANT: 10.00 Contract address: 0x4893b8ed3ce0e589563c6cd59e5b58499f32de94 Network: Mainnet Paid to: oivoodoo Visit https://openbounty.status.im to learn more.

linuxchip commented 6 years ago

@onbjerg , i want to take this. Which file is this ?

Thanks

onbjerg commented 6 years ago

@linuxchip Multiple files. You will have to adjust the scanner, parser and evaluator. I think a good starting point would be to check how multiplication works in the interpreter :)

linuxchip commented 6 years ago

@onbjerg , thanks for the input. I will start working on this

onbjerg commented 6 years ago

Cool! Let me know if you have questions 😊

linuxchip commented 6 years ago

@onbjerg , just one quick question.

Which interpreter you are mentioning here ?

onbjerg commented 6 years ago

@linuxchip The Radspec interpreter

linuxchip commented 6 years ago

@onbjerg , i checked aragon/radspec directory, but somehow i am not getting exactly.

I see multiplication code in parser/index.js at line 150 ( is this you are mentioning to check how multiplication works in interpreter ? )

multiplication () { let node = this.unary()

while (this.matches('SLASH', 'STAR')) {
  let operator = this.previous().type
  let right = this.unary()

  node = {
    type: 'BinaryExpression',
    operator,
    left: node,
    right
  }
}

return node

}

Thanks

onbjerg commented 6 years ago

That's the parser. It takes in tokens (in this case, for multiplication, it is the STAR token).

The parser takes in tokens and generates an Abstract Syntax Tree which is then read by the evaluator to actually perform the multiplication.

oivoodoo commented 6 years ago

@onbjerg could you check the transfer?

oivoodoo commented 6 years ago

@onbjerg it's still status Pending maintainer confirmation. Could you check it? it would be great to verify that it's transferable

oivoodoo commented 6 years ago

@onbjerg and again write you about the pending status :)

luisivan commented 6 years ago

@oivoodoo we are confirming bounties now, payout should arrive shortly

oivoodoo commented 6 years ago

@luisivan, it looks like I received it. in this time I setup metamask and bounty program properly. Thank you!