Permalink
Browse files

Merge branch 'master' into gh-pages

  • Loading branch information...
2 parents 5b9bbbc + 867b4d6 commit 4d3afadcc751e1c9caa65cfd0f5082098990b781 @ich committed Mar 30, 2012
View
Oops, something went wrong.
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var CoffeeScript, runScripts;
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var Lexer, RESERVED, compile, fs, lexer, parser, path, vm, _ref,
__hasProp = {}.hasOwnProperty;
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var BANNER, CoffeeScript, EventEmitter, Import, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, forkNode, fs, helpers, hidden, joinTimeout, lint, loadRequires, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, writeJs, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var extend, flatten;
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var key, val, _ref;
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref, _ref1,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
@@ -112,21 +112,21 @@
var binaryLiteral, lexedLength, match, number, octalLiteral;
if (!(match = NUMBER.exec(this.chunk))) return 0;
number = match[0];
- if (/E/.test(number)) {
- this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'");
- } else if (/[BOX]/.test(number)) {
+ if (/^0[BOX]/.test(number)) {
this.error("radix prefix '" + number + "' must be lowercase");
- } else if (/^0[89]/.test(number)) {
+ } else if (/E/.test(number) && !/^0x/.test(number)) {
+ this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'");
+ } else if (/^0\d*[89]/.test(number)) {
this.error("decimal literal '" + number + "' must not be prefixed with '0'");
- } else if (/^0[0-7]/.test(number)) {
+ } else if (/^0\d+/.test(number)) {
this.error("octal literal '" + number + "' must be prefixed with '0o'");
}
lexedLength = number.length;
- if (octalLiteral = /0o([0-7]+)/.exec(number)) {
- number = (parseInt(octalLiteral[1], 8)).toString();
+ if (octalLiteral = /^0o([0-7]+)/.exec(number)) {
+ number = '0x' + (parseInt(octalLiteral[1], 8)).toString(16);
}
- if (binaryLiteral = /0b([01]+)/.exec(number)) {
- number = (parseInt(binaryLiteral[1], 2)).toString();
+ if (binaryLiteral = /^0b([01]+)/.exec(number)) {
+ number = '0x' + (parseInt(binaryLiteral[1], 2)).toString(16);
}
this.token('NUMBER', number);
return lexedLength;
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, Comment, Existence, Extends, FileSystem, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, Import, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Lexer, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Package, Param, Parens, Path, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, compact, del, ends, extend, flatten, last, merge, multident, parser, starts, unfoldSoak, utility, _ref, _ref1,
__hasProp = {}.hasOwnProperty,
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments;
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var ACCESSOR, CoffeeScript, Module, REPL_PROMPT, REPL_PROMPT_CONTINUATION, REPL_PROMPT_MULTILINE, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, enableColours, error, getCompletions, inspect, multilineMode, pipedInput, readline, repl, run, stdin, stdout;
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
@@ -1,4 +1,4 @@
-// Generated by Caffeine 0.1.9
+// Generated by Caffeine 0.2.0
(function() {
var Scope, extend, last, _ref;
View
@@ -133,19 +133,19 @@ exports.Lexer = class Lexer
numberToken: ->
return 0 unless match = NUMBER.exec @chunk
number = match[0]
- if /E/.test number
- @error "exponential notation '#{number}' must be indicated with a lowercase 'e'"
- else if /[BOX]/.test number
+ if /^0[BOX]/.test number
@error "radix prefix '#{number}' must be lowercase"
- else if /^0[89]/.test number
+ else if /E/.test(number) and not /^0x/.test number
+ @error "exponential notation '#{number}' must be indicated with a lowercase 'e'"
+ else if /^0\d*[89]/.test number
@error "decimal literal '#{number}' must not be prefixed with '0'"
- else if /^0[0-7]/.test number
+ else if /^0\d+/.test number
@error "octal literal '#{number}' must be prefixed with '0o'"
lexedLength = number.length
- if octalLiteral = /0o([0-7]+)/.exec number
- number = (parseInt octalLiteral[1], 8).toString()
- if binaryLiteral = /0b([01]+)/.exec number
- number = (parseInt binaryLiteral[1], 2).toString()
+ if octalLiteral = /^0o([0-7]+)/.exec number
+ number = '0x' + (parseInt octalLiteral[1], 8).toString 16
+ if binaryLiteral = /^0b([01]+)/.exec number
+ number = '0x' + (parseInt binaryLiteral[1], 2).toString 16
@token 'NUMBER', number
lexedLength
View
@@ -69,3 +69,8 @@ test "#2060: Disallow uppercase radix prefixes and exponential notation", ->
program = "0#{char}0"
doesNotThrow -> CoffeeScript.compile program, bare: yes
throws -> CoffeeScript.compile program.toUpperCase(), bare: yes
+
+test "#2224: hex literals with 0b or B or E", ->
+ eq 176, 0x0b0
+ eq 177, 0x0B1
+ eq 225, 0xE1

0 comments on commit 4d3afad

Please sign in to comment.