PLOGHELP SIMPLEPOP Jonathan Laventhol July 1983 Revised by Kathryn Seifert August 1986 Library package to do simple things in Pop11 from Prolog Keywords: Pop11, Prolog, mixed language programming, library CONTENTS - (Use g to access sections) -- INTRODUCTION -- SIMPLEST FORM -- GETTING RESULTS -- ERROR RECOVERY -- VARIABLES -- QUOTE SIGNS INSIDE THE POP-11 CODE -- STRINGS, WORDS AND ATOMS -- RELATED DOCUMENTATION -- INTRODUCTION ------------------------------------------------------- If you want to do fairly simple things in Pop11 from within Prolog, there is a library package, SIMPLEPOP, to help you. If you want the full flexibility, you should see PLOGHELP * PLOGTOPOP and PLOGHELP * MIXED_LANGUAGES. SIMPLEPOP allows you to use normal Pop11 syntax. It provides three predicates: dopop/1, dopop/2, and dopopreturn/2. These predicates are explained below. To load LIBRARY SIMPLEPOP, type: ?- library(simplepop). -- SIMPLEST FORM ------------------------------------------------------ Once you have the library file loaded you can give a string or an atom of Pop11 code to the Prolog predicate dopop/1: ?- dopop("1234 =>"). ** 1234 yes If the Pop11 code leaves results on the stack then they will be ignored; if a mishap happens the goal fails. -- GETTING RESULTS ---------------------------------------------------- If you want to get results back from the Pop11 code, use dopop/2 -- a list of the results, if any, will be unified with the second argument: ?- dopop("100 + 2; 300 + pi", Results). Results = [102, 303.142] ? yes -- ERROR RECOVERY ----------------------------------------------------- If you really want to get the mishap message, you can use dopopreturn/2. This is like dopop/2, but if there is a mishap, then a Prolog term indicating the error will be unified with the results variable: ?- dopopreturn("100 + nil", X). X = pop_mishap(NUMBER(S) NEEDED, [100, []], [+, sysEXECUTE, pop11_exec_stmnt_seq_to, sysCOMPILE, pop11_comp_stream, compile]) ? yes The term 'pop_mishap' has three arguments -- the error message, the "culprits", and a shortened list of the calling sequence. -- VARIABLES ---------------------------------------------------------- To set a Pop11 variable do: ?- dopop("78 -> poplinemax;"). To examine a Pop11 variable do: ?- dopop("poplinemax", Poplinemax). Poplinemax = 78 ? See HELP * POPVARS for a list of variables which it might be useful to set. -- QUOTE SIGNS INSIDE THE POP-11 CODE --------------------------------- If you need the double quote sign in the Pop11 code, then you should give the Pop11 code in an atom: ?- dopop(' "hello" => '). ** hello yes If you need single quotes, make sure you use a Prolog string: ?- dopop(" 'hello there' => "). ** hello there yes If you need both, do this: ?- dopop(' \'hello\' >< "there" => '). ** hellothere yes -- STRINGS, WORDS AND ATOMS ------------------------------------------- In Pop11, Strings are surrounded by single quotes: 'a pop11 string'. Words are surrounded by double quotes: "aword" Values of variables have no quotes In Prolog, Strings are surrounded by double quotes: "a prolog string". Atoms are surrounded by single quotes if they have certain characters in them: 'a funny atom' -- RELATED DOCUMENTATION ---------------------------------------------- PLOGHELP * ARE Library for evaluating Pop11 expressions with any number of results from Prolog PLOGHELP * IS Evaluating Pop11 expressions which return 1 result from Prolog PLOGHELP * LIBRARIES Overview of Prolog library programs PLOGHELP * MIXED_LANGUAGES Overview of methods of interfacing Prolog and other languages PLOGHELP * PLOGTOPOP How to call Pop11 from Prolog PLOGHELP * POPSTRING How to put Pop11 strings in Prolog programs PLOGHELP * POPTOPLOG How to call Prolog from Pop11 PLOGHELP * PROLOG_EVAL How to evaluate the Prolog representation of a Pop11 expression PLOGHELP * PROLOG_LANGUAGE Predicates and library package for switching from Prolog to Pop11 PLOGHELP * PROLOG_SETQ reading and writing Pop11 variables from Prolog. PLOGHELP * TERMSINPOP Facilities for manipulating Prolog terms and variables in Pop11 --- C.all/plog/help/simplepop ------------------------------------------ --- Copyright University of Sussex 1991. All rights reserved. ----------