1 # This file is part of the pep8analysis project (http://xymus.net/pep8/)
3 # Copyright 2013-2014 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Web version of the pep8analysis tool
19 # Takes the entire Pep/8 source code as argument and prints out the
20 # analysis results. The result graph will be sent to the JavaScript function
21 # `show_graph` with the source of the graph in Graphviz's dot.
22 module pep8analysis_web
32 redef class AnalysisManager
36 var stream
= new StringIStream(src
)
37 var ast
= build_ast
("web", stream
)
43 var model
= build_model
(ast
)
46 if model
.lines
.is_empty
then
47 fatal_error
( ast
, "This programs appears empty" )
52 var cfg
= build_cfg
(model
)
58 do_reaching_defs_analysis
(cfg
)
61 do_range_analysis
(ast
, cfg
)
64 do_types_analysis
(ast
, cfg
)
67 if notes
.is_empty
then print
"Success: Nothing wrong detected"
69 var of
= new StringOStream
70 cfg
.print_dot
(of
, true)
79 fun show_graph
(content
: String) do "show_graph('{content.escape_to_c}');".run_js
85 init(str
: String) do _buffer
= new FlatBuffer.from
(str
)
87 redef fun fill_buffer
do end_reached
= true
88 redef var end_reached
: Bool = false
92 redef fun manager
do return once
new AnalysisManager
95 manager
.run args
.first