cecco974 / jsdoc-toolkit

Automatically exported from code.google.com/p/jsdoc-toolkit
0 stars 0 forks source link

Token Reader gets confused with / (div) and regex #158

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Source example:
/** Test file */
function example () {
   var a = 15 / 3;
   var b = 4 / 2;
}

Token Reader thinks that / 3; var b = 4 / is a REGX Token. It works if I 
change the example to:

/** Test file */
function example () {
   var a = 15/3;
   var b = 4/2;
}

Allways when there is a / preceded by a SPACE it's handled like a REGX 
Token.

Code before:
JSDOC.TokenReader.prototype.read_regx = function(/**JSDOC.TokenStream*/
stream, tokens) {
    if (
        stream.look() == "/" 

Solution:
JSDOC.TokenReader.prototype.read_regx = function(/**JSDOC.TokenStream*/
stream, tokens) {
    if (
        stream.look() == "/" && stream.look(1) != " "

This change will cause that a regexp like / / will not be detected but 
this is less common than div operator preceded by SPACE but I think that 
/ / is commonly represented like /\s/.

Excuse me for my poor English.

Original issue reported on code.google.com by tobias.c...@gmail.com on 20 Jun 2008 at 7:53

GoogleCodeExporter commented 8 years ago

Original comment by micmath on 21 Jun 2008 at 2:17

GoogleCodeExporter commented 8 years ago
I can't test it now until monday... but I think my solution is not correct. The
following case will not work

Source example:
/** Test file */
function example () {
   var a = 15 /3;
   var b = 4 /2;
}

Original comment by tobias.c...@gmail.com on 21 Jun 2008 at 6:05

GoogleCodeExporter commented 8 years ago
The problem is actually elsewhere, but I've already found a fix, I'm just 
testing it further before I commit it.

Original comment by micmath on 21 Jun 2008 at 6:07

GoogleCodeExporter commented 8 years ago

Original comment by micmath on 2 Aug 2008 at 8:21

GoogleCodeExporter commented 8 years ago

Original comment by micmath on 2 Aug 2008 at 8:21