fixing up block comment indentation boondoggle.
This commit is contained in:
parent
269f4e8da8
commit
07d9e9b71e
|
@ -162,10 +162,10 @@
|
|||
}
|
||||
this.line += count(match[1], "\n");
|
||||
this.i += match[1].length;
|
||||
if (match[4]) {
|
||||
this.token('HERECOMMENT', this.sanitizeHeredoc(match[4], {
|
||||
if (match[2]) {
|
||||
this.token('HERECOMMENT', this.sanitizeHeredoc(match[2], {
|
||||
herecomment: true,
|
||||
indent: match[3]
|
||||
indent: new Array(this.indent + 1).join(' ')
|
||||
}));
|
||||
this.token('TERMINATOR', '\n');
|
||||
}
|
||||
|
@ -614,7 +614,7 @@
|
|||
HEREDOC = /^("{6}|'{6}|"{3}([\s\S]*?)\n?([ \t]*)"{3}|'{3}([\s\S]*?)\n?([ \t]*)'{3})/;
|
||||
OPERATOR = /^(-[\-=>]?|\+[+=]?|[*&|\/%=<>^:!?]+)([ \t]*)/;
|
||||
WHITESPACE = /^([ \t]+)/;
|
||||
COMMENT = /^(([ \t]*\n)*([ \t]*)###([^#][\s\S]*?)(###[ \t]*\n|(###)?$)|(\s*#(?!##[^#])[^\n]*)+)/;
|
||||
COMMENT = /^(###([^#][\s\S]*?)(###[ \t]*\n|(###)?$)|(\s*#(?!##[^#])[^\n]*)+)/;
|
||||
CODE = /^((-|=)>)/;
|
||||
MULTI_DENT = /^((\n([ \t]*))+)(\.)?/;
|
||||
LAST_DENTS = /\n([ \t]*)/g;
|
||||
|
|
|
@ -138,8 +138,9 @@ exports.Lexer = class Lexer
|
|||
return false unless match = @chunk.match(COMMENT)
|
||||
@line += count match[1], "\n"
|
||||
@i += match[1].length
|
||||
if match[4]
|
||||
@token 'HERECOMMENT', @sanitizeHeredoc match[4], herecomment: true, indent: match[3]
|
||||
if match[2]
|
||||
@token 'HERECOMMENT', @sanitizeHeredoc match[2],
|
||||
herecomment: true, indent: new Array(@indent + 1).join(' ')
|
||||
@token 'TERMINATOR', '\n'
|
||||
true
|
||||
|
||||
|
@ -523,7 +524,7 @@ NUMBER = /^(((\b0(x|X)[0-9a-fA-F]+)|((\b[0-9]+(\.[0-9]+)?|\.[0-9]+)(e[+\-
|
|||
HEREDOC = /^("{6}|'{6}|"{3}([\s\S]*?)\n?([ \t]*)"{3}|'{3}([\s\S]*?)\n?([ \t]*)'{3})/
|
||||
OPERATOR = /^(-[\-=>]?|\+[+=]?|[*&|\/%=<>^:!?]+)([ \t]*)/
|
||||
WHITESPACE = /^([ \t]+)/
|
||||
COMMENT = /^(([ \t]*\n)*([ \t]*)###([^#][\s\S]*?)(###[ \t]*\n|(###)?$)|(\s*#(?!##[^#])[^\n]*)+)/
|
||||
COMMENT = /^(###([^#][\s\S]*?)(###[ \t]*\n|(###)?$)|(\s*#(?!##[^#])[^\n]*)+)/
|
||||
CODE = /^((-|=)>)/
|
||||
MULTI_DENT = /^((\n([ \t]*))+)(\.)?/
|
||||
LAST_DENTS = /\n([ \t]*)/g
|
||||
|
|
|
@ -67,12 +67,11 @@ ok test is 'test test test'
|
|||
Kind of like a heredoc.
|
||||
###
|
||||
|
||||
# FIXME:
|
||||
# func = ->
|
||||
# ###
|
||||
# Another block comment.
|
||||
# ###
|
||||
# code
|
||||
func = ->
|
||||
###
|
||||
Another block comment.
|
||||
###
|
||||
code
|
||||
|
||||
func = ->
|
||||
one = ->
|
||||
|
|
Loading…
Reference in New Issue