<commit_before># This file is part of the pep8analysis project (http://xymus.net/pep8/)
#
# Copyright 2013-2014 <NAME> <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Web version of the pep8analysis tool
#
# Takes the entire Pep/8 source code as argument and prints out the
# analysis results. The result graph will be sent to the JavaScript function
# `show_graph` with the source of the graph in Graphviz's dot.
module pep8analysis_web

import emscripten

import backbone
import ast
import model
import cfg
import flow_analysis

redef class AnalysisManager

	fun run(src: String)
	do
		var stream = new StringIStream(src)
		var ast = build_ast("web", stream)
		assert ast != null

		if failed then exit 1

		# Build program model
		var model = build_model(ast)
		if failed then exit 1

		if model.lines.is_empty then
			fatal_error( ast, "This programs appears empty" )
			exit 1
		end

		# Create CFG<commit_msg>pep8analysis: do not crash on expected errors<commit_after># This file is part of the pep8analysis project (http://xymus.net/pep8/)
#
# Copyright 2013-2014 <NAME> <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Web version of the pep8analysis tool
#
# Takes the entire Pep/8 source code as argument and prints out the
# analysis results. The result graph will be sent to the JavaScript function
# `show_graph` with the source of the graph in Graphviz's dot.
module pep8analysis_web

import emscripten

import backbone
import ast
import model
import cfg
import flow_analysis

redef class AnalysisManager

	fun run(src: String)
	do
		var stream = new StringIStream(src)
		var ast = build_ast("web", stream)
		if ast == null then return

		if failed then exit 1

		# Build program model
		var model = build_model(ast)
		if failed then exit 1

		if model.lines.is_empty then
			fatal_error( ast, "This programs appears empty" )
			return
		end

		# Create CFG
{'fraction_non_alphanumeric': 0.06535269709543569, 'fraction_numerical': 0.013831258644536652, 'mean_word_length': 4.04006968641115, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2264485', 'n_tokens_mistral': 873, 'n_tokens_neox': 803, 'n_words': 394}