Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Octal escape sequences error #19

Open
portacustodis opened this issue Apr 28, 2012 · 18 comments
Open

Octal escape sequences error #19

portacustodis opened this issue Apr 28, 2012 · 18 comments

Comments

@portacustodis
Copy link

Trying to work through the book, I get the following error when running prelude:

SyntaxError: In /Users/portacustodis/Desktop/smooth/src/prelude/prelude.coffee, octal escape sequences "\033[32m#{str}\033[0m" are not allowed on line 218
    at SyntaxError (unknown source)
    at Lexer.error (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:686:13)
    at Lexer.stringToken (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:174:14)
    at Lexer.tokenize (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:35:137)
    at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:43:32
    at Object..coffee (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:19:17)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)

When I comment the offending lines out to see what happens, I get this:

SyntaxError: In /Users/portacustodis/Desktop/smooth/src/prelude/coffeekup.coffee, reserved word "yield" on line 215
    at SyntaxError (unknown source)
    at Lexer.error (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:686:13)
    at Lexer.identifierToken (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:88:16)
    at Lexer.tokenize (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/lexer.js:35:19)
    at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:43:32
    at Object..coffee (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:19:17)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)

I'm using CoffeeScript version 1.3.1 running on NodeJS version 0.6.15 with the latest version of Smooth Coffee cloned directly from GitHub.

@portacustodis
Copy link
Author

Researched the issue and found that it seems to be related to strict JavaScript compliance (see siwilkins' comment on the Mercury project). Changing the '0' to 'x' on the lines specifying the colors (lines 218, 220, and 222 of prelude.coffee) as per CoffeeScript's cake file fixes the first issue. However, I still get the second issue about 'yield', which I'm looking into next.

@portacustodis
Copy link
Author

Found that the 'yield' issue is caused by CoffeeScript making 'yield' a reserved word (see this thread). Apparently, it has been solved in a fork of CoffeeKup by replacing 'yield' with 'cede' (see CoffeeCup project).

In case anyone else runs into these issues, I was able to get up and running by:

  1. dropping the contents of CoffeeCup's src directory into the prelude directory,
  2. changing the require in prelude from coffeekup to coffeecup, and
  3. installing the node module uglify-js.

This works well enough for me to use to work through the book in Textmate (with useColors turned off) using Cmd+R to run longer code blocks and at the command line for shorter examples. However, for some reason, at the command line, the output is displayed twice and I'm not certain that the colors are actually working...

@autotelicum
Copy link
Owner

Thanks for reporting this. I haven't tried 1.31 yet. It sounds like an update of the source code is needed. I will try to reproduce the issues one of the next days, as soon as i can. It is really nice of you to investigate the causes.

@portacustodis
Copy link
Author

It's the least I can do - it's really nice of you to write the book & maintain this code!

If there's anything else I can do, let me know. I'm also testing a setup using browserify to be able to work through the book strictly through the browser. If I get something going in that vein, I'll try to document it somewhere for others.

@rballonline
Copy link

FYI: Got the latest node (0.7.8) and coffeescript (1.3.1) and it's happening for me as well when I tried the "Optional Smooth CoffeeScript" and "Optional Test WebSockets" steps on this page: http://autotelicum.github.com/Smooth-CoffeeScript/literate/install-notes.html. I'm going to try to continue but feeling a bit nervous ;)

@rballonline
Copy link

Tried to follow portacustodis's advice but got stuck at running "npm install coffeecup" on the command line, with a "Error: No compatible version found: stylus@'>=0.25.0'". I'll try just running in browser for now.

@portacustodis
Copy link
Author

@wtilton - You don't install coffeecup with npm. You just need to clone it from GitHub and copy the contents of its src directory into the prelude directory, as per the instructions above (number 1).

@mountainjoe
Copy link

I forked the project and followed @portacustodis instructions. It's available here: https://github.com/mountainjoe/Smooth-CoffeeScript. The code runs fine and I think the colors work too.

@sunnyrjuneja
Copy link

Tried your fork @mountainjoe. Worked fine after I did npm install uglify-js and stylus except for

coffee 10-TestWebSockets.coffee
Server running at
{ port: 8000,
family: 2,
address: '0.0.0.0' }
Open a web browser at: http://127.0.0.1:8000/

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: listen EADDRINUSE
at errnoException (net.js:670:11)
at Array.0 (net.js:771:26)
at EventEmitter._tickCallback (node.js:192:40)

@mountainjoe
Copy link

@whatasunnyday I suspect you're already running a web server on port 8000. Try changing the port in the code to something less common like 7856.

@sunnyrjuneja
Copy link

That seemed to clear one problem. Any idea why the websocket test would fail? I'm getting

WebSocket Test

ERROR: undefined

DISCONNECTED

@mountainjoe
Copy link

That happens to me too. It may have to do with security settings on the browser. See: https://github.com/autotelicum/Smooth-CoffeeScript/blob/master/src/prelude/prelude.coffee#L38

I tried Firefox v12 and Chrome 19-something and both seemed disconnected or having issues. Safari 5.1 worked fine. It is unlikely that your coffee installation is at fault.

@sunnyrjuneja
Copy link

Thanks Mountainjoe. I'll try again in Safari.

@jacobopolavieja
Copy link

Same issue here. Seems to get fixed with Mountainjoe's src packages and installing uglify-js and stylus.

Thank you!

@mrstlee
Copy link

mrstlee commented Jun 16, 2012

Used Mountainjoe's fork - some of the test scripts still require coffeekup so I got the 'yield' problem. Easy enough to fix - change the require or link coffeekup to coffeecup etc.

@mtunjic
Copy link

mtunjic commented Jun 22, 2012

try this:

  1. first install coffeecup (npm install coffeecup -g)
  2. delete cofeecup files in prelude folder
  3. open ../perlude/prelude.coffee
    a) go to line 200 then replece require './coffee' with require 'coffeecup'
    b) replace 0 with x (ln 219)\
 passed: (str) -> # print message in green
    console.log if useColors then "\x33[32m#{str}\x33[0m" else str
  invalid: (str) -> # print message in yellow
    console.warn if useColors then "\x33[33m#{str}\x33[0m" else str
  failure: (str) -> # print message in red
    console.error if useColors then "\x33[31m#{str}\x33[0m" else str

@csage
Copy link

csage commented Jul 14, 2012

That immediately worked for me. Although this should be obvious for anyone reading the code, please note that in the current version of the repository

  • in line 200 the original text reads: require './coffeekup'
  • the other three lines to be changed were 218, 220, and 222
  • what you need to do there is change \033 to \x033 in both places on each of the lines

And that indeed does the trick. Thanks a lot to attractor for making this work again!

@rpattabi
Copy link

I had to do the following to make it work:

  1. git clone git://github.com/mountainjoe/Smooth-CoffeeScript.git
  2. cd into that src directory
  3. npm install uglify-js stylus

PS: I am complete novice. Please forgive me if there is something elementary here.

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

No branches or pull requests

10 participants