From: Alexis Laferrière Date: Sun, 15 Jun 2014 13:27:21 +0000 (-0400) Subject: pep8analysis: enable analyzing from stream X-Git-Tag: v0.6.6~24^2~10 X-Git-Url: http://nitlanguage.org pep8analysis: enable analyzing from stream Signed-off-by: Alexis Laferrière --- diff --git a/contrib/pep8analysis/src/ast/ast_base.nit b/contrib/pep8analysis/src/ast/ast_base.nit index 7054d29..6759fcc 100644 --- a/contrib/pep8analysis/src/ast/ast_base.nit +++ b/contrib/pep8analysis/src/ast/ast_base.nit @@ -2,11 +2,15 @@ import backbone import parser redef class AnalysisManager - fun build_ast( filename : String ) : nullable AListing + fun build_ast_from_file( filename : String ) : nullable AListing do var file = new IFStream.open( filename ) + return build_ast(filename, file) + end - var source = new SourceFile(filename, file) + fun build_ast(filename: String, stream: IStream): nullable AListing + do + var source = new SourceFile(filename, stream) var lexer = new Lexer(source) var parser = new Parser(lexer) var node_tree = parser.parse diff --git a/contrib/pep8analysis/src/ast/pretty_instructions.nit b/contrib/pep8analysis/src/ast/pretty_instructions.nit index 7616b7e..488d382 100644 --- a/contrib/pep8analysis/src/ast/pretty_instructions.nit +++ b/contrib/pep8analysis/src/ast/pretty_instructions.nit @@ -12,7 +12,7 @@ redef class AnalysisManager opts.add_option(opt_ast) end - redef fun build_ast(filename) + redef fun build_ast(filename, stream) do var ast = super diff --git a/contrib/pep8analysis/src/ast/rich_instructions.nit b/contrib/pep8analysis/src/ast/rich_instructions.nit index 8049e34..947693e 100644 --- a/contrib/pep8analysis/src/ast/rich_instructions.nit +++ b/contrib/pep8analysis/src/ast/rich_instructions.nit @@ -13,7 +13,7 @@ intrude import parser import ast_base redef class AnalysisManager - redef fun build_ast(filename) + redef fun build_ast(filename, stream) do var ast = super if ast != null then diff --git a/contrib/pep8analysis/src/pep8analysis.nit b/contrib/pep8analysis/src/pep8analysis.nit index 1c334e6..c4d660f 100644 --- a/contrib/pep8analysis/src/pep8analysis.nit +++ b/contrib/pep8analysis/src/pep8analysis.nit @@ -48,7 +48,7 @@ redef class AnalysisManager print "Target file \"{filename}\" does not exist." exit 1 end - var ast = build_ast( filename ) + var ast = build_ast_from_file( filename ) assert ast != null if failed then continue