SPEAGRAM BUILT-IN AND CORE LANGUAGE REFERENCE
Speagram Built-in Language
Class ''bit''.
Element ''bit'' ''0'' as bit.
Element ''bit'' ''1'' as bit.
Class ''char''.
Element ''char'' ''code'' bit bit bit bit bit bit bit bit as char.
Class ''term'' ''type''.
Class term type ''list''.
Element ''['' '']'' as ?a list.
Element ?a '','' ?a list as ?a list.
Class ''string''.
Element ''string'' ''from'' char list as string.
Class ''boolean''.
Element ''true'' as boolean.
Element ''false'' as boolean.
Class ''ternary'' ''truth'' ''value''.
Element ''true'' as ternary truth value.
Element ''unknown'' as ternary truth value.
Element ''false'' as ternary truth value.
Element ''?'' string as term type.
Element ''type'' string '':'' term type list as term type.
Element ''funtype'' term type list ''-'' ''>'' term type as term type.
Class ''syntax'' ''element''.
Element ''''' ''''' string ''''' ''''' as syntax element.
Element term type as syntax element.
Class ''syntax'' ''element'' ''sequence''.
Element syntax element as syntax element sequence.
Element syntax element syntax element sequence as syntax element sequence.
Class ''syntax'' ''definition''.
Element ''class'' syntax element sequence as syntax definition.
Element ''element'' syntax element sequence ''as'' term type as syntax
definition.
Element ''function'' syntax element sequence ''as'' term type as syntax
definition.
Element ''variable'' syntax element sequence ''as'' term type as syntax
definition.
Class ''term''.
Element ''var'' string '':'' term type '':'' bit list ''('' term list
'')'' as term.
Element ''term'' string ''('' term list '')'' as term.
Class ''constructor''.
Element ''constructor'' string ''from'' term type list ''to'' term type as
constructor.
Class ''rewrite'' ''rule''.
Element ''rewrite'' term ''to'' term as rewrite rule.
Class ''input'' ''rewrite'' ''rule'' ''of'' term type.
Element ''let'' ?a_1 ''be'' ?a_1 as input rewrite rule of ?a_1.
Class ''priority'' ''input'' ''rewrite'' ''rule'' ''of'' term type.
Element ''let'' ''major'' ?a_1 ''be'' ?a_1
as priority input rewrite rule of ?a_1.
Class ''function'' ''definition''.
Element ''function'' string ''from'' term type list ''to'' term type as
function definition.
Class ''class'' ''definition''.
Element ''class'' ''of'' term type as class definition.
Function ''('' ?b '')'' as ?b.
Function ''<'' ''|'' ?b ''|'' ''>'' as ?b.
Function ''if'' boolean ''then'' ?a ''else'' ?a as ?a.
Function ''code'' ?a ''as'' ''term'' as term.
Function ''get'' ''class'' ''definitions'' as class definition list.
Function ''get'' ''function'' ''definitions'' as function definition list.
Function ''get'' ''constructors'' as constructor list.
Class ''outside'' ''paths''.
Element ''library'' '':'' ''/'' string as outside paths.
Element ''file'' '':'' ''/'' string as outside paths.
Class ''load'' ''command''.
Element ''load'' ''state'' outside paths as load command.
Class ''system'' ''commands'' ''of'' term type.
Element ''close'' ''context'' as system commands of ?a_1.
Class term type ''exception''.
Element ''!'' ''!'' ?a ''!'' ''!'' as ?other_than_a exception.
Element ''+'' ''+'' ?a ''+'' ''+'' as ?a exception.
Function term ''parsed'' ''preferred'' ''to'' term as ternary truth value.
Class ''logic'' ''formula''.
Element ?a ''='' ?a as logic formula.
Element ''not'' logic formula as logic formula.
Element logic formula ''and'' logic formula as logic formula.
Element logic formula ''or'' logic formula as logic formula.
Element ''exists'' ?a '':'' logic formula as logic formula.
Element ''for'' ''all'' ?a '':'' logic formula as logic formula.
Function ''does'' logic formula ''hold'' ''looking'' ''at'' logic formula
list as ternary truth value.
Function ''prompt'' ''for'' logic formula ''looking'' ''at'' logic formula
list as logic formula list.
Class ''logic'' ''definition''.
Element ''axiom'' logic formula as logic definition.
Element ''search'' ''for'' logic formula ''with'' ''height'' ''limit'' bit
list as logic definition.
Element ''relation'' syntax element sequence ''given'' ''by'' logic
formula ''looking'' ''at'' logic formula list as logic definition.
Function ''additional'' ''xslt'' as string.
Function ''"'' string ''"'' as string.
Function ''get'' ''formulas'' as logic formula list.
Function ?a ''='' ?a as boolean.
Speagram Core Library
// SHORTHAND FOR OCAML LIKE LIST NOTATION.
// This shorthand was previously the default notation and is used extensively.
Function ?a '':'' '':'' ?a list as ?a list.
Let e :: l be e, l.
// SHORTHAND FOR "IS A" AND "IS AN" FOR CONSTRUCTORS.
Function syntax element sequence ''is'' ''a'' term type as syntax definition.
Function syntax element sequence ''is'' ''an'' term type as syntax definition.
Function syntax element sequence ''is'' term type as syntax definition.
// APPEND AND STRING PLUS.
Function ''append'' ?a list ''to'' ?a list as ?a list.
Function string ''+'' string as string.
// BASIC OPERATION - FUNCTION TO ALLOW NOTATION WITH NEW ___.
Function ''new'' syntax definition as syntax definition.
Let new sd be sd.
// SHORTHAND SYNTAX NOTATION.
New function ''variable'' string ''as'' term type as syntax definition.
Let variable sa as tt be variable ''sa'' as tt.
New function ''variable'' string string ''as'' term type as syntax definition.
New function ''variable'' string string string ''as'' term type
as syntax definition.
New function ''variable'' string string string string ''as'' term type
as syntax definition.
New function ''''' ''''' string string ''''' ''''' as syntax element sequence.
New function ''''' ''''' string string ''''' ''''' syntax element sequence
as syntax element sequence.
New function ''''' ''''' string string string ''''' '''''
as syntax element sequence.
New function ''''' ''''' string string string ''''' '''''
syntax element sequence as syntax element sequence.
// UNIT TYPE.
New class ''unit class''.
New element ''unit'' as unit class.
// FUNCTIONS ON BOOLEANS.
New function boolean ''as boolean'' as boolean.
New function boolean ''and'' boolean as boolean.
New function boolean ''or'' boolean as boolean.
New function ''not'' boolean as boolean.
// FUNCTIONS ON TERNARY TRUTH VALUES.
New function ''reduce'' ternary truth value list ''starting''
''with'' ternary truth value as ternary truth value.
New function ''reduce'' ternary truth value list
as ternary truth value.
// FUNCTION TO COMPARE STRING NAMES TO DECIDE IF THE NAMES CORRESPOND.
// These are used in establishing preferences for terms.
New function ''is digit'' string as boolean.
New function ''added ending'' char list as boolean.
New function ''corresponding names'' ''after first'' string ''and'' string
as boolean.
New function ''corresponding names'' string ''and'' string as boolean.
// THE MAIN PREFERENCE FUNCTIONS.
New function term list ''better'' term list as ternary truth value list.
// THIS SAYS THAT IF ___ ELSE X F IS IF ___ (X F) NOT (IF ___ X) F.
// ANALOGOUS TO THE ABOVE FOR F WITH ARITY 2.
// ANALOGOUS TO THE ABOVE FOR F WITH ARITY 3.
// STRINGS SHOULD NOT BE TAKEN WHEN BOTTOM ALTERNATIVE IS POSSIBLE.
// THE GENERAL PREFERENCES RULE IF OTHER DO NOT APPLY.
Let term s_1 (tl_1) parsed preferred to term s_2 (tl_2) be
if corresponding names s_1 and s_2 then reduce tl_1 better tl_2 else unknown.
Let var s : ty_1 : bl_1 (tl_1) parsed preferred to var s : ty_2: bl_2 (tl_2) be
reduce tl_1 better tl_2.
// THE FOLLOWING MUST BE APPLIED AS LAST RESORT.
Let t_1 parsed preferred to t_2 be unknown.
// SOME BASIC FUNCTION ON TERMS THAT WE WANT TO USE.
New function term ''equal modulo types'' ''to'' term as boolean.
New function term list ''equal modulo types'' ''to'' term list as boolean.
// GENERATING RULES TO MAKE THE FUNCTION GIVEN BY NAME A WEAK CAST.
New function ''see'' string ''as non default'' ''cast'' ''for''
term ''and'' term as
(priority input rewrite rule of ternary truth value) list.
New function ''see'' string ''as'' ''non'' ''default'' ''cast'' as
(priority input rewrite rule of ternary truth value) list.
// SIMPLE ANTI-CAST RULES, HERE FOR TWO STANDARD CASTS (FROM BUILTIN LANGUAGE).
See "C\?" as non default cast.
See "C\?_0\" as non default cast.
// GETTING THE NAME OF LAST DEFINED FUNCTION AND SETTING IT AS CAST.
New function ''last fun name'' ''from'' function definition list as string.
New function ''last cons name'' ''from'' constructor list as string.
New function ''see last function'' ''as'' ''cast'' as
(priority input rewrite rule of ternary truth value) list.
New function ''see last element'' ''as'' ''cast'' as
(priority input rewrite rule of ternary truth value) list.
// GENERATING PREFERENCE RULE FOR A PAIR OF TERMS.
New function ''see'' ?a ''preferred to different'' ?b as
(priority input rewrite rule of ternary truth value) list.
New function ''see'' ?a ''preferred to'' ?a as
(priority input rewrite rule of ternary truth value) list.
// PREFERENCE FOR BOOLEANS OVER TERNARY TRUTH VALUES.
New function ternary truth value ''as ternary truth'' ''value''
as ternary truth value.
See true as boolean preferred to different true as ternary truth value.
See false as boolean preferred to different false as ternary truth value.
// PREFERENCE TO MAKE STRING ADDITION LEFT ASSOCIATIVE.
See (s_1 + s_2) + s_3 preferred to s_1 + (s_2 + s_3).
// SHORTHAND FOR TERM TYPE USED IN CLASS DEFINITIONS.
New function ''sth'' as syntax element.
Let sth be term type.
// ADDITIONAL IMPROVED LIST NOTATION.
New function ''['' ?a '']'' as ?a list.
Let [e1] be e1 :: [].
New function ?a '','' ?a as ?a list.
See (e1, l) preferred to different (e2, e3).
New function ?a list ''as'' ''list'' as ?a list.
// PAIRS AND TRIPLES DEFS AND PREFERENCES.
New class ''pair of'' sth ''and'' sth.
New element ''('' ?a '','' ?b '')'' as pair of ?a and ?b.
New function pair of ?a and ?b ''as'' ''pair'' as pair of ?a and ?b.
See (e1, e2) as pair preferred to different (<|(e1, e2)|> as list).
New class ''triple of'' sth ''and'' sth ''and'' sth.
New element ''('' ?a '','' ?b '','' ?c '')'' as
triple of ?a and ?b and ?c.
New function triple of ?a and ?b and ?c ''as'' ''triple''
as triple of ?a and ?b and ?c.
See (e1, e2, e3) as triple preferred to different
(<|(e1, e2, e3)|> as list).
See (e1, e2, e3) as triple preferred to different
(<|e1, e2|>, e3) as pair.
See (e1, e2, e3) as triple preferred to different
(e1, <|e2, e3|>) as pair.
New function ''first of'' triple of ?a and ?b and ?c as ?a.
New function ''second of'' triple of ?a and ?b and ?c as ?b.
New function ''third of'' triple of ?a and ?b and ?c as ?c.
New function ''first of'' pair of ?a and ?b as ?a.
New function ''second of'' pair of ?a and ?b as ?b.
// LOGIC FORMULAS TYPE CAST AND PREFERENCE AND SHORTHANDS.
New function logic formula ''as logic formula'' as logic formula.
See (b1 = b2) as boolean preferred to different (b1 = b2) as logic formula.
New function ''search'' ''for'' logic formula as logic definition.
Let search for l be
search for l with height limit bit0, bit0, bit0, bit1.
New function ''search'' ''for'' ''small'' logic formula as logic definition.
Let search for small l be
search for l with height limit bit0, bit1.
New function ''relation'' syntax element sequence ''given'' ''by''
logic formula as logic definition.
Let relation sels given by l be relation sels given by l looking at [].
// ASSERTION CHECK.
New function ''check'' boolean ''and report'' string as boolean exception.
Let check b and report s be if b then ++b++ else !!s!!.
// BASIC SHORTHAND FOR XSLT.
New function ''term'' ''name'' ''of'' ''term'' term as string.
New function ''term'' ''name'' ''of'' ?a as string.
New function ''add xslt for'' ?a ''template'' string
as priority input rewrite rule of string.