Skip to content

Conversation

@lydell
Copy link
Collaborator

@lydell lydell commented Mar 5, 2016

Fixes #4218.

AlphaNumeric: [
o 'NUMBER', -> new NumberLiteral $1
o 'INFINITY', -> new InfinityLiteral $1
o 'INFINITE_NUMBER', -> new InfiniteNumberLiteral $1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the old names. Let's not distinguish between Infinity and 2e308. They should each be an InfinityLiteral.

src/nodes.coffee Outdated
super 'NaN'

compileNode: ->
[@makeCode '(0/0)']
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with the simple approach of always wrapping in parentheses here. Do we want to only do it if strictly needed? (If so, how?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wanted to do it the better way, you could either create an Op node that represents the division and call compile on that, or you could just add the parens yourself by checking o.level. But this works fine for a first implementation if you just feel like leaving it. It's up to you.


compileNode: (o) ->
code = [@makeCode '0/0']
if o.level >= LEVEL_OP then @wrapInBraces code else code
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I settled on using @makeCode instead of new Op since that allows NaN to be rendered as 0/0 instead of 0 / 0.

@lydell
Copy link
Collaborator Author

lydell commented Mar 7, 2016

@michaelficarra Any more comments? :)

@michaelficarra
Copy link
Collaborator

Yeah, I had just wanted to clone it and try some things out myself. LGTM. Merging.

michaelficarra added a commit that referenced this pull request Mar 7, 2016
Treat Infinity and NaN as reserved words
@michaelficarra michaelficarra merged commit e318469 into jashkenas:master Mar 7, 2016
@lydell lydell deleted the infinity-nan branch March 7, 2016 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants