module "/pliant/language/compiler.pli" module "/pliant/language/stream.pli" module "/pliant/language/context.pli" module "/pliant/admin/file.pli" module "/pliant/language/ui/console.pli"
constant execute_available os_api="linux"
if execute_available module "/pliant/admin/execute.pli"
requires "administrator"
title "Pliant interpreter"
var Str prog := options option "prog" Str var Int level := options option "level" Int if level=undefined level := 1 var Str mode := options option "mode" Str
text_input "Your source code:[lf]" prog columns 80 rows 20 if execute_available input "Execute at debugging level: " level length 1 noeol select " " mode option "in another process" "another" option "in this process" "this" option "administration task" "admin" button "Execute" noeol goto_url http_request:path options "prog "+string:prog+" level "+string:level+" mode "+string:mode
if prog<>"" var Str tempprog := file_temporary (var Stream temp) open tempprog out+safe if mode="admin" temp writeline "module [dq]/pliant/admin/file.pli[dq]" temp writeline "module [dq]/pliant/admin/execute.pli[dq]" temp writeline "module [dq]/pliant/linux/schedule/process.pli[dq]" temp writechars prog temp close var Str tempconsole := file_temporary if not execute_available or mode<>"another" var Link:List program :> new List (var Stream temp) open tempprog in+safe while not temp:atend program append addressof:(new Str temp:readline) pliant_compiler_semaphore request console_redirect tempconsole var Link:Module module :> new Module module name := "interpreter" module include the_module:"/pliant/language/basic/safe.pli" error_push_record (var ErrorRecord e) error_filter_all compile_text program module var Str err := shunt e:id<>error_id_noerror e:message "" e id := error_id_noerror error_pull_record e console_restore pliant_compiler_semaphore release if err<>"" table columns 1 border 0 cell color (color hsl 0 50 75) text "Error message:" ; eol cell color (color hsl 0 50 85) fixed text err else
|
execute "/bin/pliant debug "+string:level+" module /pliant/language/ui/console.pli command console_redirect:[dq]"+tempconsole+"[dq] "+file_os_name:tempprog
|
execute "/bin/pliant debug "+string:level+" module /pliant/install/minimal.pli module /pliant/language/ui/console.pli command console_redirect:[dq]"+tempconsole+"[dq] "+file_os_name:tempprog
|
para table columns 1 border 0 cell color (color hsl 60 50 75) text "Output:" ; eol cell color (color hsl 60 50 85) (var Stream temp) open tempconsole in+safe fixed while not temp:atend text temp:readline ; eol temp close para table columns 1 border 0 cell color (color hsl 30 50 75) text "Listing:" cell color (color hsl 30 50 85) (var Stream temp) open tempprog in+safe fixed while not temp:atend html "<font size=-3>" text (string temp:line_number+1)+":" html "</font>" text " "+temp:readline ; eol temp close file_delete tempprog file_delete tempconsole
|