From cd6dd5abfd9ab6780c430539175b8d6618d604cb Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sun, 28 Feb 2010 21:39:07 -0500 Subject: [PATCH] couple more tweaks to lexer.coffee --- lib/lexer.js | 10 +++++----- src/lexer.coffee | 13 +++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index 24506d8a..638dcff4 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -7,7 +7,7 @@ // // [tag, value, line_number] // - // Which is a format that can be fed directly into Jison. + // Which is a format that can be fed directly into [Jison](http://github.com/zaach/jison). // Set up the Lexer for both Node.js and the browser, depending on where we are. if ((typeof process !== "undefined" && process !== null)) { Rewriter = require('./rewriter').Rewriter; @@ -17,7 +17,7 @@ } // Constants // --------- - // Keywords that CoffeScript shares in common with JS. + // Keywords that CoffeeScript shares in common with JavaScript. JS_KEYWORDS = ["if", "else", "true", "false", "new", "return", "try", "catch", "finally", "throw", "break", "continue", "for", "in", "while", "delete", "instanceof", "typeof", "switch", "super", "extends", "class"]; // CoffeeScript-only keywords, which we're more relaxed about allowing. They can't // be used standalone, but you can reference them as an attached property. @@ -68,7 +68,7 @@ // Tokens that indicate an access -- keywords immediately following will be // treated as identifiers. ACCESSORS = ['PROPERTY_ACCESS', 'PROTOTYPE_ACCESS', 'SOAK_ACCESS', '@']; - // Tokens that, when immediately preceding a 'WHEN', indicate that the 'WHEN' + // Tokens that, when immediately preceding a `WHEN`, indicate that the `WHEN` // occurs at the start of a line. We disambiguate these from trailing whens to // avoid an ambiguity in the grammar. BEFORE_WHEN = ['INDENT', 'OUTDENT', 'TERMINATOR']; @@ -298,7 +298,7 @@ return true; }; // We treat all other single characters as a token. Eg.: `( ) , . !` - // Multi-character operators are also literal tokens, so that Racc can assign + // Multi-character operators are also literal tokens, so that Jison can assign // the proper order of operations. Lexer.prototype.literal_token = function literal_token() { var match, not_spaced, tag, value; @@ -338,7 +338,7 @@ }; // Token Manipulators // ------------------ - // As we consume a new IDENTIFIER, look at the previous token to determine + // As we consume a new `IDENTIFIER`, look at the previous token to determine // if it's a special kind of accessor. Lexer.prototype.name_access_type = function name_access_type() { if (this.value() === '::') { diff --git a/src/lexer.coffee b/src/lexer.coffee index 212743c3..02ca7f27 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -5,7 +5,7 @@ # # [tag, value, line_number] # -# Which is a format that can be fed directly into Jison. +# Which is a format that can be fed directly into [Jison](http://github.com/zaach/jison). # Set up the Lexer for both Node.js and the browser, depending on where we are. if process? @@ -17,7 +17,7 @@ else # Constants # --------- -# Keywords that CoffeScript shares in common with JS. +# Keywords that CoffeeScript shares in common with JavaScript. JS_KEYWORDS: [ "if", "else", "true", "false", @@ -98,7 +98,7 @@ CALLABLE: ['IDENTIFIER', 'SUPER', ')', ']', '}', 'STRING', '@'] # treated as identifiers. ACCESSORS: ['PROPERTY_ACCESS', 'PROTOTYPE_ACCESS', 'SOAK_ACCESS', '@'] -# Tokens that, when immediately preceding a 'WHEN', indicate that the 'WHEN' +# Tokens that, when immediately preceding a `WHEN`, indicate that the `WHEN` # occurs at the start of a line. We disambiguate these from trailing whens to # avoid an ambiguity in the grammar. BEFORE_WHEN: ['INDENT', 'OUTDENT', 'TERMINATOR'] @@ -258,7 +258,7 @@ exports.Lexer: class Lexer true # We treat all other single characters as a token. Eg.: `( ) , . !` - # Multi-character operators are also literal tokens, so that Racc can assign + # Multi-character operators are also literal tokens, so that Jison can assign # the proper order of operations. literal_token: -> match: @chunk.match(OPERATOR) @@ -289,7 +289,7 @@ exports.Lexer: class Lexer # Token Manipulators # ------------------ - # As we consume a new IDENTIFIER, look at the previous token to determine + # As we consume a new `IDENTIFIER`, look at the previous token to determine # if it's a special kind of accessor. name_access_type: -> @tag(1, 'PROTOTYPE_ACCESS') if @value() is '::' @@ -372,7 +372,8 @@ exports.Lexer: class Lexer # ----------------- # Does a list include a value? -include: (list, value) -> list.indexOf(value) >= 0 +include: (list, value) -> + list.indexOf(value) >= 0 # Count the number of occurences of a character in a string. count: (string, letter) ->