Utilities/ClassBrowsers/jsclbr.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3441
1b07f996e9ee
child 3591
2f2a4a76dd22
--- a/Utilities/ClassBrowsers/jsclbr.py	Sun Mar 30 22:00:14 2014 +0200
+++ b/Utilities/ClassBrowsers/jsclbr.py	Thu Apr 03 23:05:31 2014 +0200
@@ -11,7 +11,8 @@
 
 from __future__ import unicode_literals
 
-import ThirdParty.Jasy.jasy.js.parse.Parser as jsParser
+import jasy.js.parse.Parser as jsParser
+import jasy.js.tokenize.Tokenizer as jsTokenizer
 
 import Utilities
 import Utilities.ClassBrowsers as ClassBrowsers
@@ -93,9 +94,16 @@
         self.__root = None
         self.__stack = []
         
-        self.__source = src
         self.__module = module
         self.__file = filename
+        self.__source = src
+        
+        # normalize line endings
+        self.__source = self.__source.replace("\r\n", "\n").replace("\r", "\n")
+        
+        # ensure source ends with an eol
+        if self.__source[-1] != '\n':
+            self.__source = self.__source + '\n'
     
     def parse(self):
         """
@@ -104,10 +112,13 @@
         @return dictionary containing the parsed information
         """
         try:
-            self.__root = jsParser.parse(self.__source)
+            self.__root = jsParser.parse(self.__source, self.__file)
             self.__visit(self.__root)
         except jsParser.SyntaxError:
-            # ignore syntax errors
+            # ignore syntax errors of the parser
+            pass
+        except jsTokenizer.ParseError:
+            # ignore syntax errors of the tokenizer
             pass
         
         return self.__dict

eric ide

mercurial