<commit_before>'use strict'

{
	setupEditors
	setupSamples
	setupCompilers
	setupRunButton
	saveProgram
	loadProgram
} = window.viz


prettify = (code) ->
	# workarounds until js_beautify gets fixed
	# https://github.com/beautify-web/js-beautify/issues/815
	semicolons = code.replace /([\w)])$/gm, '$1;'
	beautified = js_beautify semicolons
	beautified.replace /;$/gm, ''


run = (editors, compiler) ->
	saveProgram editors

	playfield = new bef.Playfield editors.source.getValue(), { size: 'standard' }

	runtime = new bef.EagerRuntime()
	runtime.execute(
		playfield
		{ jumpLimit: 1000, compiler }
		editors.input.getValue()
	)

	prettyJs = prettify runtime.code

	editors.js.setValue prettyJs, 1

	stringedStack = do ->
		{ stack } = runtime.programState
		if stack.length > 512
			"""
				#{(stack.slice 0, 256).join ' '}
				...<commit_msg>Raise limit on the eager evaluator demo<commit_after>'use strict'

{
	setupEditors
	setupSamples
	setupCompilers
	setupRunButton
	saveProgram
	loadProgram
} = window.viz


prettify = (code) ->
	# workarounds until js_beautify gets fixed
	# https://github.com/beautify-web/js-beautify/issues/815
	semicolons = code.replace /([\w)])$/gm, '$1;'
	beautified = js_beautify semicolons
	beautified.replace /;$/gm, ''


run = (editors, compiler) ->
	saveProgram editors

	playfield = new bef.Playfield editors.source.getValue(), { size: 'standard' }

	runtime = new bef.EagerRuntime()
	runtime.execute(
		playfield
		{ compiler, jumpLimit: Infinity }
		editors.input.getValue()
	)

	prettyJs = prettify runtime.code

	editors.js.setValue prettyJs, 1

	stringedStack = do ->
		{ stack } = runtime.programState
		if stack.length > 512
			"""
				#{(stack.slice 0, 256).join ' '}
				...
{'fraction_non_alphanumeric': 0.13240418118466898, 'fraction_numerical': 0.016260162601626018, 'mean_word_length': 3.746556473829201, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '7235925', 'n_tokens_mistral': 682, 'n_tokens_neox': 607, 'n_words': 130}