[javascriptlint-commit] SF.net SVN: javascriptlint:[211] trunk/pyjsl
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2008-08-23 22:25:00
|
Revision: 211 http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=211&view=rev Author: matthiasmiller Date: 2008-08-23 22:24:59 +0000 (Sat, 23 Aug 2008) Log Message: ----------- Break part of jsparse.parse into jsparse.parsecomments. Modified Paths: -------------- trunk/pyjsl/jsparse.py trunk/pyjsl/lint.py Modified: trunk/pyjsl/jsparse.py =================================================================== --- trunk/pyjsl/jsparse.py 2008-08-23 21:58:12 UTC (rev 210) +++ trunk/pyjsl/jsparse.py 2008-08-23 22:24:59 UTC (rev 211) @@ -179,11 +179,12 @@ msg = msg[6:].lower() error_callback(line, col, msg) - positions = NodePositions(script) + return pyspidermonkey.parse(script, _Node, _wrapped_callback) - roots = [] - nodes = [] +def parsecomments(script, root_node): + positions = NodePositions(script) comment_ignore_ranges = NodeRanges() + def process(node): if node.kind == tok.NUMBER: node.atom = positions.text(node.start_pos(), node.end_pos()) @@ -195,16 +196,10 @@ for kid in node.kids: if kid: process(kid) - def pop(): - nodes.pop() + process(root_node) - root_node = pyspidermonkey.parse(script, _Node, _wrapped_callback) - if root_node: - process(root_node) + return _parse_comments(script, root_node, positions, comment_ignore_ranges) - comments = _parse_comments(script, root_node, positions, comment_ignore_ranges) - return root_node, comments - def is_compilable_unit(script): return pyspidermonkey.is_compilable_unit(script) @@ -220,12 +215,13 @@ def dump_tree(script): def error_callback(line, col, msg): print '(%i, %i): %s', (line, col, msg) - node, comments = parse(script, error_callback) + node = parse(script, error_callback) _dump_node(node) class TestComments(unittest.TestCase): def _test(self, script, expected_comments): - root, comments = parse(script, lambda line, col, msg: None) + root = parse(script, lambda line, col, msg: None) + comments = parsecomments(script, root) encountered_comments = [node.atom for node in comments] self.assertEquals(encountered_comments, list(expected_comments)) def testSimpleComments(self): Modified: trunk/pyjsl/lint.py =================================================================== --- trunk/pyjsl/lint.py 2008-08-23 21:58:12 UTC (rev 210) +++ trunk/pyjsl/lint.py 2008-08-23 22:24:59 UTC (rev 211) @@ -176,7 +176,8 @@ return lint_error(pos.line, pos.col, errname) parse_errors = [] - root, comments = jsparse.parse(script, parse_error) + root = jsparse.parse(script, parse_error) + comments = jsparse.parsecomments(script, root) ignores = [] start_ignore = None declares = [] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |