7 Parse a JavaScript file and retrieve variables and functions. |
7 Parse a JavaScript file and retrieve variables and functions. |
8 |
8 |
9 It uses the JavaScript parser contained in the jasy web framework. |
9 It uses the JavaScript parser contained in the jasy web framework. |
10 """ |
10 """ |
11 |
11 |
12 import ThirdParty.Jasy.jasy.js.parse.Parser as jsParser |
12 import jasy.js.parse.Parser as jsParser |
13 import ThirdParty.Jasy.jasy.js.tokenize.Tokenizer as jsTokenizer |
13 import jasy.js.tokenize.Tokenizer as jsTokenizer |
14 |
14 |
15 import Utilities |
15 import Utilities |
16 import Utilities.ClassBrowsers as ClassBrowsers |
16 import Utilities.ClassBrowsers as ClassBrowsers |
17 from . import ClbrBaseClasses |
17 from . import ClbrBaseClasses |
18 |
18 |
101 Public method to parse the source. |
101 Public method to parse the source. |
102 |
102 |
103 @return dictionary containing the parsed information |
103 @return dictionary containing the parsed information |
104 """ |
104 """ |
105 try: |
105 try: |
106 self.__root = jsParser.parse(self.__source) |
106 self.__root = jsParser.parse(self.__source, self.__file) |
107 self.__visit(self.__root) |
107 self.__visit(self.__root) |
108 except jsParser.SyntaxError: |
108 except jsParser.SyntaxError: |
109 # ignore syntax errors of the parser |
109 # ignore syntax errors of the parser |
110 pass |
110 pass |
111 except jsTokenizer.ParseError: |
111 except jsTokenizer.ParseError: |
112 # ignore syntax errors of the tokenizer |
112 # ignore syntax errors of the tokenizer |
113 pass |
|
114 except Exception: |
|
115 # ignore syntax errors of the tokenizer and parser |
|
116 pass |
113 pass |
117 |
114 |
118 return self.__dict |
115 return self.__dict |
119 |
116 |
120 def __visit(self, root): |
117 def __visit(self, root): |