Tuesday, August 14, 2012

Parse Error: Unexpected POST_IF

Following a coffeescript tutorial from nettuts, I encountered this error after entering the following on REPL...
coffee> name = "jim"
coffee> if name is "jim"

Soon as I hit enter after typing the second line, i got these error messages...
Error: In repl, Parse error on line 1: Unexpected 'POST_IF'
    at Object.parseError (/usr/lib/node_modules/coffee-script/lib/coffee-script/parser.js:477:11)
    at Object.parse (/usr/lib/node_modules/coffee-script/lib/coffee-script/parser.js:554:22)
    at exports.compile.compile (/usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:43:20)
    at Object.exports.eval (/usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:140:10)
    at run (/usr/lib/node_modules/coffee-script/lib/coffee-script/repl.js:131:41)
    at ReadStream. (/usr/lib/node_modules/coffee-script/lib/coffee-script/repl.js:173:9)
    at ReadStream.EventEmitter.emit (events.js:88:17)
    at TTY.onread (net.js:395:14)

If you know how I can fix this, kindly let me know by using the comment box below.

In the meantime, I am going to google for a solution now. I'll update this post soon as I find a solution.



EDIT

I was thinking the parse error had something to do with syntax, but I wasn't sure. I decided to download and install the vim plugin, "kchmck / vim-coffee-script" into ~/.vim.

I then ran the script, coffee a.coffee... No more errors!

Weird, but it must have been the whitespace. But how come I was getting the parse error when I ran the script on REPL?

No comments:

Post a Comment