allowed /**/ comment (close #34)
This commit is contained in:
@@ -89,6 +89,7 @@ class Test {
|
|||||||
test("-2 == 3 - 5", true);
|
test("-2 == 3 - 5", true);
|
||||||
test("var x=-3; x", -3);
|
test("var x=-3; x", -3);
|
||||||
test("var a:Array<Dynamic>=[1,2,4]; a[2]", 4, null, true);
|
test("var a:Array<Dynamic>=[1,2,4]; a[2]", 4, null, true);
|
||||||
|
test("/**/0", 0);
|
||||||
trace("Done");
|
trace("Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-7
@@ -1066,7 +1066,7 @@ class Parser {
|
|||||||
while( true ) {
|
while( true ) {
|
||||||
char = readChar();
|
char = readChar();
|
||||||
if( !ops[char] ) {
|
if( !ops[char] ) {
|
||||||
if( op.charCodeAt(0) == 47 )
|
if( op.charCodeAt(0) == '/'.code )
|
||||||
return tokenComment(op,char);
|
return tokenComment(op,char);
|
||||||
this.char = char;
|
this.char = char;
|
||||||
return TOp(op);
|
return TOp(op);
|
||||||
@@ -1095,9 +1095,9 @@ class Parser {
|
|||||||
function tokenComment( op : String, char : Int ) {
|
function tokenComment( op : String, char : Int ) {
|
||||||
var c = op.charCodeAt(1);
|
var c = op.charCodeAt(1);
|
||||||
var s = input;
|
var s = input;
|
||||||
if( c == 47 ) { // comment
|
if( c == '/'.code ) { // comment
|
||||||
try {
|
try {
|
||||||
while( char != 10 && char != 13 ) {
|
while( char != '\r'.code && char != '\n'.code ) {
|
||||||
incPos();
|
incPos();
|
||||||
char = s.readByte();
|
char = s.readByte();
|
||||||
}
|
}
|
||||||
@@ -1106,18 +1106,22 @@ class Parser {
|
|||||||
}
|
}
|
||||||
return token();
|
return token();
|
||||||
}
|
}
|
||||||
if( c == 42 ) { /* comment */
|
if( c == '*'.code ) { /* comment */
|
||||||
var old = line;
|
var old = line;
|
||||||
|
if( op == "/**/" ) {
|
||||||
|
this.char = char;
|
||||||
|
return token();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
while( true ) {
|
while( true ) {
|
||||||
while( char != 42 ) {
|
while( char != '*'.code ) {
|
||||||
if( char == 10 ) line++;
|
if( char == '\n'.code ) line++;
|
||||||
incPos();
|
incPos();
|
||||||
char = s.readByte();
|
char = s.readByte();
|
||||||
}
|
}
|
||||||
incPos();
|
incPos();
|
||||||
char = s.readByte();
|
char = s.readByte();
|
||||||
if( char == 47 )
|
if( char == '/'.code )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch( e : Dynamic ) {
|
} catch( e : Dynamic ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user