in
5 | {
6 | cell(Init) => let {
7 | I : Init;
8 |
9 | get() => I;
10 | set(X){
11 | I := X;
12 | }
13 | } in (get,set);
14 | } export cell
--------------------------------------------------------------------------------
/Tests/num.go:
--------------------------------------------------------------------------------
1 | num{
2 | import go.unit.
3 | import go.io.
4 |
5 | numtest:[]@=harness.
6 | numtest<=harness.
7 | numtest..{
8 | doPred() :-
9 | (34).equal(34).
10 | }.
11 |
12 | main(_) ->
13 | checkUnit(numtest).
14 | }
--------------------------------------------------------------------------------
/BootCompiler/error.go:
--------------------------------------------------------------------------------
1 | /*
2 | * The base exception class module
3 | */
4 |
5 | error{
6 | syserror[] <~ { cause:(()=>string), code:(()=>symbol) }.
7 |
8 | error(Cause,Code):syserror[]..{
9 | cause()=>Cause.
10 | code()=>Code.
11 | }
12 | }
--------------------------------------------------------------------------------
/Tests/track.go:
--------------------------------------------------------------------------------
1 | track{
2 | import go.io.
3 |
4 | a:[symbol]{}.
5 | b:[symbol]{}.
6 | c:[symbol]{}.
7 |
8 | a(X) :- b(X), c(X).
9 |
10 | b('a').
11 | b('c').
12 |
13 | c('c').
14 |
15 | main(_) ->
16 | a(X) *> stdout.outLine(X.show()).
17 | }
--------------------------------------------------------------------------------
/tdpl/num.tdpl:
--------------------------------------------------------------------------------
1 | -- Number grammar
2 |
3 | Number -> Integer / Real.
4 |
5 | Integer -> Digit / Integer Digit.
6 |
7 | Real -> Integer Fraction Scale.
8 | Fraction -> "." Integer.
9 | Scale -> "e" Sign Integer / ().
10 |
11 | Digit -> [0-9].
12 | Sign -> [-+].
13 |
--------------------------------------------------------------------------------
/Agent/CVS/Entries:
--------------------------------------------------------------------------------
1 | /agent.gh/1.1.1.1/Sat Aug 2 22:16:13 2003//
2 | /agent.go/1.1.1.1/Sat Aug 2 22:16:13 2003//
3 | /contract.gh/1.1.1.1/Sat Aug 2 22:16:13 2003//
4 | /interpret.gh/1.1.1.1/Sat Aug 2 22:16:13 2003//
5 | /interpret.go/1.1.1.1/Sat Aug 2 22:16:13 2003//
6 | D
7 |
--------------------------------------------------------------------------------
/Tests/show.go:
--------------------------------------------------------------------------------
1 | show{
2 | import go.io.
3 | import bintree.
4 |
5 | tree[T] ::= leaf(T) | node(tree[T],tree[T]).
6 |
7 | sample:tree[symbol] = node(node(leaf('a'),leaf('b')),leaf('c')).
8 |
9 | main(_) ->
10 | stdout.outLine([sample].show()).
11 | }
12 |
--------------------------------------------------------------------------------
/Tests/lazy.go:
--------------------------------------------------------------------------------
1 | /*
2 | * A first test of the lazy evaluation feature
3 | */
4 | lazy{
5 | import go.io.
6 |
7 | data('a').
8 | data('b').
9 |
10 | check('b').
11 |
12 | lazy() :- data(X@@check(X)).
13 |
14 | main(_) ->
15 | { lazy() }.
16 | }.
17 |
18 |
--------------------------------------------------------------------------------
/Tests/first.go:
--------------------------------------------------------------------------------
1 | first{
2 | -- The first program to try out
3 |
4 | -- import go.io.
5 |
6 | p:[symbol]{}.
7 | p('a').
8 | p('b').
9 |
10 | q:[symbol]{}.
11 | q('b').
12 |
13 | n:[symbol]{}.
14 | n(X) :- p(X),q(X).
15 |
16 | main(_) ->
17 | {n(X)}.
18 | }
--------------------------------------------------------------------------------
/Tests/x.go:
--------------------------------------------------------------------------------
1 | x{
2 | import go.io.
3 | import go.xml.
4 | import go.stream.
5 |
6 | main(Files) ->
7 | Fl in Files *>
8 | inStream = inputSequence(openInFile(Fl,utf8Encoding),0);
9 | { xmlParse(X)-->inStream };
10 | stdout.outLine(X.show()).
11 | }
12 |
--------------------------------------------------------------------------------
/Doc/.cvsignore:
--------------------------------------------------------------------------------
1 | Makefile
2 | Makefile.in
3 | *.dvi
4 | *.log
5 | *.lot
6 | *.gls
7 | *.glo
8 | *.aux
9 | *.out
10 | *.junk
11 | *.toc
12 | *.bl
13 | .deps
14 | .libs
15 | go-ref.pdf
16 | mnem.tex
17 | mnem
18 | ops.tex
19 | ops
20 | esc.tex
21 | esc
22 | *.ind
23 | *.ilg
24 | *.idx
25 | .DS_Store
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Makefile
2 | Makefile.in
3 | go.spec
4 | config.cache
5 | config.h
6 | config.log
7 | config.status
8 | configure
9 | libtool
10 | stamp-h
11 | stamp-h1
12 | go.Make
13 | config.h.in
14 | aclocal.m4
15 | go*.rpm
16 | go*.tgz
17 | config.guess
18 | config.sub
19 | .DS_Store
20 | .gdb_history
21 |
22 |
--------------------------------------------------------------------------------
/Tests/smtp.go:
--------------------------------------------------------------------------------
1 | smtp{
2 | import go.smtp.
3 | import go.io.
4 | import go.unit.
5 |
6 | smtpTest:[string]@=harness.
7 | smtpTest(H)..{
8 | doAction() ->
9 | Email = email("frankmccabe@mac.com","This is a test from Go",[]);
10 | config(H,"mac.com","frankmccabe");
11 | Email.post().
12 | }.
13 | }
--------------------------------------------------------------------------------
/goSSL/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile.am to build the Go! OpenSSL libraries
3 | #
4 |
5 | lib_LTLIBRARIES = libgossl.la
6 |
7 | noinst_HEADERS = gossl.h gosslP.h
8 |
9 | libgossl_la_SOURCES = gossl.c
10 |
11 | INCLUDES = -I@top_srcdir@/Headers -I@top_srcdir@/Engine/Headers -I@ooiodir@/include '-DGODIR=@prefix@"'
--------------------------------------------------------------------------------
/BootCompiler/.cvsignore:
--------------------------------------------------------------------------------
1 | Makefile
2 | Makefile.in
3 | *.aam
4 | *.af
5 | *.goc
6 | *.gf
7 | *.gof
8 | esc.ap
9 | mnem.ap
10 | ecode.ap
11 | ops.ap
12 | instr.ah
13 | trace
14 | *~
15 | *.o
16 | instr
17 | mnem
18 | esccode
19 | esc
20 | ops
21 | ntrace
22 | .deps
23 | .libs
24 | .gdb_history
25 | goc
26 | go.Make
27 |
--------------------------------------------------------------------------------
/CVS/Base/.cvsignore:
--------------------------------------------------------------------------------
1 | Makefile
2 | Makefile.in
3 | go.spec
4 | config.cache
5 | config.h
6 | config.log
7 | config.status
8 | configure
9 | libtool
10 | stamp-h
11 | stamp-h1
12 | go.Make
13 | config.h.in
14 | aclocal.m4
15 | go*.rpm
16 | go*.tgz
17 | config.guess
18 | config.sub
19 | .DS_Store
20 | .gdb_history
21 |
22 |
--------------------------------------------------------------------------------
/forOSX/Welcome.html:
--------------------------------------------------------------------------------
1 | This is the Go! language system
2 |
3 | This package installs the Go! compiler, run-time engine, sample programs and documentation.
4 |
5 | The April language system are required before the Go! system can execute.
6 |
7 | For more information, contact Francis McCabe <fgm@fla.fujitsu.com>
8 |
--------------------------------------------------------------------------------
/BootCompiler/vtest.go:
--------------------------------------------------------------------------------
1 | -- A test of module-level variables
2 |
3 | vtest{
4 | foo := 1.5.
5 | bar = "a"<>"b".
6 |
7 | ex(X) ->
8 | foo:=X*foo.
9 |
10 | main(A) ->
11 | {__logmsg("foo = "<>foo^0)};
12 | ex(23);
13 | {__logmsg("foo = "<>foo^0)};
14 | ex(foo);
15 | {__logmsg("foo = "<>foo^0)}.
16 | }
--------------------------------------------------------------------------------
/goXlib/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile.am to build the Go! Xlib libraries
3 | #
4 |
5 | lib_LTLIBRARIES = libxgo.la
6 |
7 | noinst_HEADERS = goX.h
8 |
9 | libxgo_la_SOURCES = xdisplay.c xcolor.c xwindow.c xevent.c xgc.c xdraw.c\
10 | xtext.c
11 |
12 | INCLUDES = @X_CFLAGS@ -I@top_srcdir@/Headers -I@top_srcdir@/Engine/Headers -I@ooiodir@/include '-DGODIR=@prefix@"'
--------------------------------------------------------------------------------
/Tests/world.go:
--------------------------------------------------------------------------------
1 | /*
2 | * This acts as a demonstrator for the unit test framework
3 | */
4 |
5 | world{
6 | import go.io.
7 | import go.unit.
8 |
9 | worldtest:[]@=harness.
10 |
11 | worldtest<=harness.
12 | worldtest..{
13 | doAction()->
14 | stdout.outLine("hello world").
15 | }.
16 |
17 | main(_)->
18 | checkUnit(worldtest).
19 | }
--------------------------------------------------------------------------------
/Tests/debugtest.go:
--------------------------------------------------------------------------------
1 | debugtest{
2 | import go.io.
3 |
4 | -- This is intended as a kind of test of the debugger
5 |
6 | -- First of all we have a function to debug
7 | f1:[integer]=>integer.
8 | f1(0) => 1.
9 | f1(X) => valof{
10 | I = f1(X-1);
11 | valis I*X
12 | }.
13 |
14 | main(_) ->
15 | stdout.outLine("f1(7) = "<>f1(7).show()).
16 | }
--------------------------------------------------------------------------------
/tdpl/test.tdpl:
--------------------------------------------------------------------------------
1 | -- A test grammar
2 |
3 | exp -> additive.
4 |
5 | additive -> L=mult Op=add_op R=additive { apply(Op,L,R).
6 | additive -> mult { $1 }.
7 |
8 | add_op -> "+" / "-".
9 |
10 | mult -> L=prim O=mult_op R=mult { apply(O,L,R) }.
11 | mult -> prim.
12 |
13 | mult_op -> "*"/"/".
14 |
15 | prim -> number / identifier / "(" exp ")".
16 |
17 | number -> "-"?[0-9]+.
--------------------------------------------------------------------------------
/BootCompiler/circ.go:
--------------------------------------------------------------------------------
1 | circ{
2 | -- This tests circularity checking in the compiler
3 |
4 | t[T]<~{pull:[]=>T. }.
5 |
6 | v1:integer = v2.
7 |
8 | v2:integer = v1+2.
9 |
10 | c:[integer]@>t[integer].
11 |
12 | c(I)..{
13 | x1:integer := I+x2.
14 |
15 | x2:integer := x3+v1.
16 |
17 | x3:integer := x1+v2.
18 |
19 | pull()=>x1.
20 | }.
21 |
22 | }
--------------------------------------------------------------------------------
/Tests/threads.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test out some ideas about threads
3 | */
4 |
5 | threads{
6 | import go.thread.
7 | import go.io.
8 |
9 |
10 | newthread<=thread.
11 | newthread:thread[]..{
12 | start() -> stdout.outLine(self^0<>" has forked").
13 | }.
14 |
15 | main(_) ->
16 | H = __fork($newthread,true);
17 | stdout.outLine("Child is "<>H^0).
18 | }
--------------------------------------------------------------------------------
/Tests/obTest.go:
--------------------------------------------------------------------------------
1 | obTest{
2 | import go.io.
3 | import go.unit.
4 |
5 | lbl <~ thing.
6 | lbl:[symbol,symbol,list[(symbol,symbol)]] @> lbl.
7 | lbl(A,B,L) .. {
8 | show() =>
9 | "A = "<>A.show()<>
10 | "\nB = "<>B.show()<>
11 | "\nL = "<>L.show().
12 | }.
13 |
14 | main(_) ->
15 | O=lbl(A,B,[('A',A),('B',B)]);
16 | stdout.outLine(O.show()).
17 | }
18 |
--------------------------------------------------------------------------------
/go/vector.go:
--------------------------------------------------------------------------------
1 | vector{
2 | -- Vector manipulations
3 | import go.hash.
4 |
5 | vector[t] <~ { ix:[integer]=>t. set:[integer,t]*. count:[]=>integer. }.
6 |
7 |
8 | vector:[integer]@>vector[t].
9 | vector(len)..{
10 | cont:hash[integer,t] = hash([],len).
11 |
12 | ix(K) => cont.find(K).
13 | set(K,Vl) -> cont.insert(K,Vl).
14 | count()=>cont.count().
15 | }.
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/Makefile.am:
--------------------------------------------------------------------------------
1 | ## Process this with automake to generate Makefile.in
2 |
3 | SUBDIRS = macros Headers Engine BootCompiler go golex gpg\
4 | rdf dl mysql tdpl Tests GoCompiler Doc
5 |
6 | lisp_LISP = go.el godebug.el
7 |
8 | go.elc: godebug.elc
9 |
10 | ELCFILES = go.elc godebug.elc
11 |
12 | EXTRA_DIST = go.spec go.spec.in go.el godebug.el
13 |
14 | rpm:
15 | rpm -bb go.spec
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Tests/stest.go:
--------------------------------------------------------------------------------
1 | stest{
2 | import go.cell.
3 | import go.io.
4 |
5 | test(x) ->
6 | sync(x) {
7 | action { stdout.outLine("Trying sync test") },false -> {}
8 | } timeout (now() + 1 ->
9 | stdout.outLine("Timed out")).
10 |
11 | testForEver(x) ->
12 | test(x);
13 | testForEver(x).
14 |
15 | main(_) ->
16 | x = $cell(1);
17 | testForEver(x).
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/Engine/Headers/signals.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Signal management functions
3 | */
4 | #ifndef _G_SIGNAL_H_
5 | #define _G_SIGNAL_H_
6 |
7 | #include
8 |
9 | void setupSignals(void);
10 | void startInterrupts(sigset_t blocked); /* enable control-C interrupts */
11 | sigset_t stopInterrupts(void); /* stop control-C interruptes */
12 | void go_exit(int); /* When we want to stop */
13 | void initSuspend(void);
14 | #endif
15 |
--------------------------------------------------------------------------------
/Tests/err.go:
--------------------------------------------------------------------------------
1 | err{
2 | import go.io.
3 |
4 | foo:[integer]{}.
5 | foo(0) :- raise error("This is an error",'eTEST').
6 | foo(_).
7 |
8 | errExp:[]=>integer.
9 | errExp() => raise error("This is a bad expression",'eTEST').
10 |
11 | main(_) ->
12 | { foo(errExp() onerror (
13 | error(A,B) => 23))} onerror (
14 | E -> stdout.outLine("We had the error: "<>E.show())
15 | ).
16 | }
17 |
--------------------------------------------------------------------------------
/BootCompiler/go.Make.in:
--------------------------------------------------------------------------------
1 | #
2 | # Rules for compiling go programs within the build tree
3 | #
4 | GODIR = ${top_builddir}/go
5 | GOC = ${top_builddir}/Compiler/goc
6 |
7 | %.goc: ${srcdir}/%.go ${GOC}
8 | @echo Were compiling go! program $? ":-)"
9 | GODIR=$(GODIR) $(GOC) $(GOFLAGS) $<
10 |
11 | %.gof: ${srcdir}/%.go ${GOC}
12 | @echo Were compiling go! program $? ":-)"
13 | GODIR=$(GODIR) $(GOC) +M $(GOFLAGS) $<
14 |
15 |
--------------------------------------------------------------------------------
/Tests/arith.go:
--------------------------------------------------------------------------------
1 | arith{
2 | /*
3 | * Test some of the arithmetic functions of the Go! language
4 | */
5 |
6 | import go.io.
7 | import go.unit.
8 |
9 | arithtest:[]@=harness.
10 | arithtest<=harness.
11 | arithtest..{
12 | plusOk:[]{}.
13 | plusOk() :-
14 | 1+2=3,
15 | 1.2+2.3=3.5,
16 | 1.0+3.4=4.4.
17 | doPred() :-
18 | plusOk().
19 | }.
20 |
21 | main(_) ->
22 | checkUnit(arithtest).
23 | }
--------------------------------------------------------------------------------
/forOSX/go.post_install:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Set up the paths so that April is made available to users
3 |
4 | tcshdir=/usr/share/init/tcsh
5 |
6 | if [ -f ${tcshdir}/login ]; then
7 | if ! grep -q april ${tcshdir}/login ; then
8 | cat << foobar >> ${tcshdir}/login
9 | # Automatically added by April installer
10 | # Added on `date`
11 | set path = ( \${path} /opt/april/bin )
12 | # Added on `date`
13 | foobar
14 | fi
15 | fi
16 |
--------------------------------------------------------------------------------
/forOSX/go.post_upgrade:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Set up the paths so that April is made available to users
3 |
4 | tcshdir=/usr/share/init/tcsh
5 |
6 | if [ -f ${tcshdir}/login ]; then
7 | if ! grep -q april ${tcshdir}/login ; then
8 | cat << foobar >> ${tcshdir}/login
9 | # Automatically added by April installer
10 | # Added on `date`
11 | set path = ( \${path} /opt/april/bin )
12 | # Added on `date`
13 | foobar
14 | fi
15 | fi
16 |
--------------------------------------------------------------------------------
/Tests/count.go:
--------------------------------------------------------------------------------
1 | count{
2 | import go.io.
3 |
4 | read:[inChannel,integer-]*.
5 | read(File,Count) ->
6 | loop(0,Count).
7 |
8 | private loop:[integer,integer-]*.
9 | loop(C,C)::File.eof() -> {}.
10 | loop(soFar,C) -> _ = File.inLine("\n");
11 | loop(soFar+1,C).
12 |
13 | main([F,.._]) ->
14 | read(openInFile(F,rawEncoding),Count);
15 | stdout.outLine(Count.show()<>" lines in "<>F).
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/Tests/dltest.go:
--------------------------------------------------------------------------------
1 | dltest{
2 | import dl.dl.
3 | import go.xml.
4 | import go.unit.
5 | import go.io.
6 |
7 | dlTester:[list[string]]@=harness.
8 | dlTester(_) <= harness.
9 | dlTester(Fl)..{
10 | doAction() ->
11 | kb = DlOntology("test");
12 | ( F in Fl *>
13 | importOntology(kb,F);
14 | kb.dump()
15 | ).
16 | }.
17 |
18 | main([]) -> checkUnit(dlTester(["surgery.dl"])).
19 | main(F) -> checkUnit(dlTester(F)).
20 | }.
--------------------------------------------------------------------------------
/Tests/ultest.go:
--------------------------------------------------------------------------------
1 | ultest{
2 | import go.io.
3 | import ul.
4 | import ulex.
5 |
6 | main(Files) ->
7 | F in Files *>
8 | stdout.outLine(parser(yyulex(suckIn(F),1)).show()).
9 |
10 | private suckIn:[string]=>string.
11 | suckIn(Fl) =>
12 | valof{
13 | f = openInFile(Fl,unknownEncoding);
14 | valis f.inText(""); -- This will read the entire file
15 | f.close();
16 | }.
17 | }
18 |
--------------------------------------------------------------------------------
/Tests/fact.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Factorial
3 | */
4 |
5 | fact{
6 | import go.io.
7 | import go.unit.
8 |
9 | fact:[integer]=>integer.
10 | fact(0) => 1.
11 | fact(N)::N>0 => N*fact(N-1).
12 |
13 | facttest:[]@=harness.
14 | facttest<=harness.
15 | facttest..{
16 | doPred() :-
17 | fact(10)=3628800.
18 | errorAction() ->
19 | fact(-1)=_.
20 | }.
21 |
22 | main(_) ->
23 | checkUnit(facttest).
24 | }.
25 |
--------------------------------------------------------------------------------
/Tests/individuals.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/go/comp.go:
--------------------------------------------------------------------------------
1 | comp{
2 | -- experiments in types
3 | import go.io.
4 |
5 | comp[] <~ { equal:[S]-(S<~comp[]){} }.
6 |
7 | other[T]<~comp[].
8 | other[T]<~ {
9 | more:(()=>other[T])
10 | }.
11 |
12 | d(X:T):other[T]..{
13 | equal(this).
14 |
15 | more()=>this.
16 | }.
17 |
18 | main(_) ->
19 | X = d('ab');
20 | Y = d(23);
21 | stdout.outLine(X.more()^0);
22 | stdout.outLine(Y.more()^0);
23 | }
24 |
--------------------------------------------------------------------------------
/tdpl/Makefile.am:
--------------------------------------------------------------------------------
1 | include ${top_builddir}/go.Make
2 |
3 | SUFIXES = .go .goc
4 |
5 | GO_SRCS = ctypes.go dcgparse.go canon.go cnf.go
6 |
7 | tdpl.goc: dcgparse.goc ctypes.goc canon.goc
8 |
9 | canon.goc: ctypes.goc
10 |
11 | cnf.goc: canon.goc ctypes.goc
12 |
13 | dcgparse.goc: ctypes.goc
14 |
15 | GO_CODE = $(GO_SRCS:.go=.goc)
16 |
17 | EXTRA_DIST = ${GO_SRCS}
18 |
19 | CLEANFILES = ${GO_CODE} $(GO_SRCS:.go=.gof)
20 |
21 | all-local: tdpl.goc
22 |
23 |
--------------------------------------------------------------------------------
/tdpl/tdpl.go:
--------------------------------------------------------------------------------
1 | tdpl{
2 | import go.io.
3 | import go.showable.
4 |
5 | import ctypes.
6 | import dcgparse.
7 | import canon.
8 |
9 | main(Files) ->
10 | F in Files *>
11 | ( Gr = tdplGrammar%%getFile(F,unknownEncoding);
12 | ( R in Gr *>
13 | stdout.outLine(show(R)));
14 | CNF = flatten({ canonRule(r) .. r in Gr});
15 | stdout.outLine("++ canon form:");
16 | ( R in CNF *>
17 | stdout.outLine(show(R));
18 | )).
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/Tests/f.go:
--------------------------------------------------------------------------------
1 | f{
2 | import go.io.
3 |
4 | s:[symbol,symbol]{}.
5 | s('a','b').
6 | s('a','c').
7 | s('c','d').
8 |
9 | t:[symbol]{}.
10 | t('d').
11 |
12 | c:[symbol,symbol]{}.
13 | c(X,Y) :- s(X,Y), s(Y,Z), t(Z).
14 |
15 | a:[list[t],list[t]]=>list[t].
16 | a([],X) => X.
17 | a([E,..X],Y) => [E,..a(X,Y)].
18 |
19 | main(_) ->
20 | c(X,Y) *>
21 | ( stdout.outLine("X: "<>X.show());
22 | stdout.outLine("Y: "<>Y.show())).
23 | }
--------------------------------------------------------------------------------
/go/sort.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Standard quick sorting module
3 | */
4 | go.sort{
5 | sort:[list[t],comparable[t]]=>list[t].
6 | sort([],_) => [].
7 | sort([L],_) => [L].
8 | sort([E,..L],C) => split(E,L,C,[],[]).
9 |
10 | split:[t,list[t],comparable[t],list[t],list[t]]=>list[t].
11 | split(E,[],C,L1,L2) => sort(L1,C)<>[E,..sort(L2,C)].
12 | split(E,[D,..L],C,L1,L2)::C.less(E,D) => split(E,L,C,L1,[D,..L2]).
13 | split(E,[D,..L],C,L1,L2) => split(E,L,C,[D,..L1],L2).
14 | }
--------------------------------------------------------------------------------
/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # This file is a modified version of autogen.sh in gtk+
3 | # Run this to generate all the initial makefiles, etc.
4 |
5 | aclocal -I macros
6 | autoheader
7 | automake -a
8 | autoconf
9 |
10 | case "$1" in
11 | "-r"|"--rebuild")
12 | ./config.status --recheck
13 | ./config.status
14 | ;;
15 |
16 | *)
17 | rm -f config.cache
18 | echo "$0: configure $*"
19 | ./configure $*
20 | ;;
21 | esac
22 |
23 | echo "Now type 'make' to compile"
24 |
--------------------------------------------------------------------------------
/Tests/churn.go:
--------------------------------------------------------------------------------
1 | churn{
2 | import go.io.
3 | import go.stdparse.
4 |
5 | -- A simple program to exercise the global memory by creating churn
6 |
7 | XX:list[symbol] := [].
8 |
9 | run:[integer]*.
10 | run(0)->{}.
11 | run(C)::C>0->
12 | XX := { implode(S.show()) .. S in iota(1,C)};
13 | stdout.outLine("XX is now "<>XX.show());
14 | run(C-1).
15 |
16 | main([C,.._]) ->
17 | run(naturalOf%%C).
18 | main([]) ->
19 | run(1000).
20 | }
21 |
--------------------------------------------------------------------------------
/Tests/XML/miller.rdf:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 | Eric Miller
7 |
8 | Dr.
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Tests/jsontest.go:
--------------------------------------------------------------------------------
1 | jsontest{
2 | import go.io.
3 | import go.unit.
4 | import go.json.
5 |
6 | jsontest:[list[string]]@=harness.
7 | jsontest(_)<=harness.
8 | jsontest(Fls)..{
9 | doAction() ->
10 | F in Fls *> (
11 | J = parseJson%%getFile(F,utf8Encoding);
12 | stdout.outLine("json is "<>J.show())
13 | ).
14 | }.
15 |
16 | main([]) ->
17 | checkUnit(jsontest(["test.json"])).
18 | main(Fls) ->
19 | checkUnit(jsontest(Fls)).
20 | }
21 |
--------------------------------------------------------------------------------
/BootCompiler/t.go:
--------------------------------------------------------------------------------
1 | t{
2 | thing:[]$=thing.
3 | thing..{
4 | show()::nonvar(this),__getProp(this,'$label',Lb) => explode(Lb).
5 | show() => __stringOf(this,0,0).
6 | }.
7 |
8 | false..{
9 | show() => S(this).
10 | }.
11 |
12 | true..{
13 | show() => "true".
14 | }.
15 |
16 | f:[logical]$=logical.
17 | f(T)..{
18 | show()=>T.show()
19 | }.
20 |
21 | T:logical = true.
22 |
23 | S:[logical]=>string.
24 | S(true)=>"true".
25 | S(false)=>"false".
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/Tests/celltest.go:
--------------------------------------------------------------------------------
1 | -- check out the cell library functionality
2 |
3 | celltest{
4 | import go.cell.
5 | import go.io.
6 | import go.unit.
7 |
8 | celltest:[list[string]]@=harness.
9 | celltest(_)<=harness.
10 | celltest(I)..{
11 | doAction() ->
12 | C = cell(I);
13 | stdout.outLine("C = "<>C.get().show());
14 | C.set(["foo"]);
15 | stdout.outLine("C = "<>C.get().show()).
16 | }.
17 |
18 | main(Cmd) ->
19 | checkUnit(celltest(Cmd)).
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/BootCompiler/codegen.ap:
--------------------------------------------------------------------------------
1 | /*
2 | * Module to handle some of the details of code generation
3 | */
4 | #include "go.ah";
5 | #include "instr.ah"; -- pick up the instruction definition
6 |
7 | module
8 | import
9 | {
10 | interface "display.af" and
11 | interface "misc.af" and
12 | interface
13 | }
14 | in
15 | {
16 | lblNo : 0;
17 | newLabel() => valof{
18 | XX = symbol%%([''L,..char[]%%lblNo]);
19 | lblNo := lblNo+1;
20 | valis XX
21 | };
22 |
23 |
24 | } export (newLabel)
--------------------------------------------------------------------------------
/Doc/QuickRef/preface.tex:
--------------------------------------------------------------------------------
1 | \chapter*{Preface}
2 | \go\ is a logic programming language that is oriented to the needs of secure production quality Internet based distributed applications. It is object-oriented, multi-threaded and strongly typed.
3 |
4 | It supports multi-paradigm programming styles -- with different notations for functions, predicates and action procedures.
5 |
6 | This quick guide gives a brief complete description of the \go\ language and the built-in functions that are standard with the language.
7 |
8 |
--------------------------------------------------------------------------------
/Engine/Headers/msg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * header file for message handling
3 | */
4 | #ifndef _ENGINE_MSG_H_
5 | #define _ENGINE_MSG_H_
6 |
7 | #include "word.h"
8 |
9 | /* message processing functions */
10 | void initMailBoxes(void); /* initialize message queues etc. */
11 |
12 | logical IsRealMailBox(ptrI M);
13 | processPo mailBoxOwner(ptrI M);
14 | integer mailBoxSequence(ptrI M);
15 |
16 | ptrI newMailBox(ptrI owner);
17 | void closeMailBox(ptrI M);
18 |
19 | retCode showMailBox(ioPo f,ptrI M);
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/Engine/Headers/clock.h:
--------------------------------------------------------------------------------
1 | #ifndef _CLOCK_H_
2 | #define _CLOCK_H_
3 |
4 | #include
5 |
6 | void init_time(void);
7 |
8 | void flushTimeQ();
9 | void reset_timer(void);
10 | struct timeval *nextTimeOut(void);
11 | long taxiFlag(void);
12 |
13 | number get_ticks(void);
14 | number get_time(void);
15 | integer get_date(void);
16 |
17 | #define SCHEDULETICKS 150 /* We re-schedule every 150 milliseconds */
18 |
19 | #define SECSINDAY 86400 /* Number of seconds in a day */
20 |
21 | #define NANO (1000000000)
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/Tests/xtest.go:
--------------------------------------------------------------------------------
1 | xtest{
2 | import go.io.
3 | import go.xml.
4 | import go.unit.
5 |
6 | xmltest:[list[string]]@=harness.
7 | xmltest(_)<=harness.
8 | xmltest(Fls)..{
9 | doAction() ->
10 | F in Fls *> (
11 | (_,DOM) = grabXML("file:///"<>fcwd()<>"/",F);
12 | stdout.outLine("DOM is "<>DOM.show());
13 | stdout.outLine("XML is "<>DOM.xml())).
14 | }.
15 |
16 | main([]) ->
17 | checkUnit(xmltest(["fact.xml"])).
18 | main(Fls) ->
19 | checkUnit(xmltest(Fls)).
20 | }.
21 |
22 |
--------------------------------------------------------------------------------
/Doc/preface.tex:
--------------------------------------------------------------------------------
1 | \chapter*{Preface}
2 | \go\ is a logic programming language that is oriented to the needs of secure production quality Internet based distributed applications. It is object-oriented, multi-threaded and strongly typed. It supports multi-paradigm programming styles -- with different notations for functions, predicates and action procedures.
3 |
4 | This manual offers an in-depth and complete description of the \go\ language. However, it is not a tutorial on the language, and the order of presentation within the manual reflects that.
5 |
6 |
--------------------------------------------------------------------------------
/Engine/Headers/Makefile.am:
--------------------------------------------------------------------------------
1 | # We only need to set up distribution here
2 |
3 | noinst_HEADERS = char.h errors.h heap.h signals.h unichar.h\
4 | clock.h eval.h list.h sort.h unix.h\
5 | code.h fileio.h msg.h stats.h utf.h\
6 | cons.h floats.h str.h vars.h\
7 | dbgflags.h strfile.h version.h perms.h\
8 | debug.h go.h process.h symbols.h word.h\
9 | dict.h setops.h term.h lock.h\
10 | esc.h hashtable.h global.h
11 |
12 |
--------------------------------------------------------------------------------
/go/equiv.go:
--------------------------------------------------------------------------------
1 | /*
2 | * A utility package that supports the concept of equivalence classe
3 | * Each equivalence class has a canonical member, which may have
4 | * an arbitrary set of properties associated with it
5 | */
6 | go.equiv{
7 |
8 | Equiv[T] <~ {
9 | makeSameAs:[symbol,symbol]*.
10 | makeDifferentFrom:[symbol,symbol]*.
11 | }.
12 |
13 | equiv:[list[(symbol,T)],list[(symbol,T)]]@>Equiv[T].
14 | equiv(Sm,Df)..{
15 | sameTbl:hash[symbol,T] = hash(Sm,64).
16 | diffTbl:hash[symbol,T] = hash(Df,64).
17 |
18 | }.
19 | }
--------------------------------------------------------------------------------
/BootCompiler/tree.go:
--------------------------------------------------------------------------------
1 | /*
2 | * test the type constructor form of a type definition
3 | */
4 |
5 | tree{
6 |
7 | tr[A] ::= empty | node(tr[A],A,tr[A]).
8 |
9 | tree[T] <~ { label:[]=>T }.
10 |
11 | em:[]$=tree[_].
12 | em..{
13 | label()=> raise _.
14 | }.
15 |
16 | nd:[tree[T],T,tree[T]]$=tree[T].
17 | nd(L,B,R)..{
18 | label()=>B.
19 | }.
20 |
21 | walk:[tree[t]]=>list[t].
22 | walk(nd(L,B,R)) => walk(L)<>[B]<>walk(R).
23 |
24 | (<>):[list[t],list[t]]=>list[t].
25 | []<>X=>X.
26 | [E,..X]<>Y=>[E,..X<>Y].
27 |
28 | }
--------------------------------------------------------------------------------
/Headers/CVS/Entries:
--------------------------------------------------------------------------------
1 | /.cvsignore/1.1.1.1/Sat Aug 2 22:20:10 2003//
2 | /Makefile.am/1.1.1.1/Sat Aug 2 22:20:12 2003//
3 | /encoded.h/1.1.1.1/Sat Aug 2 22:20:10 2003//
4 | /local.h/1.1.1.1/Sat Aug 2 22:20:12 2003//
5 | /opcodes.h/1.1.1.1/Sat Aug 2 22:20:12 2003//
6 | /encoding.h/1.3/Sun Aug 17 05:35:25 2003//
7 | /dll.h/1.2/Tue Sep 9 05:15:04 2003//
8 | /signature.h/1.2/Sun Dec 7 01:32:34 2003//
9 | /escapes.h/1.8/Tue Jun 29 05:46:35 2004//
10 | /instructions.h/1.4/Tue Jun 29 04:04:18 2004//
11 | /operators.h/1.7/Tue Jun 29 17:05:32 2004//
12 | D
13 |
--------------------------------------------------------------------------------
/Tests/assert.go:
--------------------------------------------------------------------------------
1 | assert{
2 | /* Test the assertion mechanism */
3 | import go.io.
4 |
5 | cType[t] <~ {
6 | length:[]=>integer.
7 | max:[]=>integer.
8 | push:[t]*/*|length()t/*|length()>0*/.
10 | $( length()cType[t].
14 | c(Mx)..{
15 | L:list[t] := [].
16 |
17 | length()=>listlen(L).
18 |
19 | max()=>Mx.
20 |
21 | push(X)->
22 | L := [X,..L].
23 |
24 | top()::[E,.._].=L=>E.
25 | }.
26 |
27 | main(_) ->
28 | CC = c(100).
29 | }
30 |
--------------------------------------------------------------------------------
/include/dx.gh:
--------------------------------------------------------------------------------
1 | /* Listener interface to the dx */
2 |
3 | -- dxListener ~> { response/((xmlDOM,string)*) }.
4 |
5 | dxMsg[T] ::= dxOk
6 | | dxError(string)
7 | | dxClicked(list[T])
8 | | dxClosed(list[T])
9 | | dxUpdated(list[T])
10 | | dxUpdated(list[T])
11 | | dxChanged(list[T])
12 | | dxActivated(list[T])
13 | | dxSelected(list[T])
14 | | dxDeselected(list[T])
15 | | dxClosed(list[T])
16 | | dxDeleted(list[T])
17 | | dxInserted(list[T])
18 | | dxMoved(list[T])
19 | | dxOther(xmlDOM).
20 |
--------------------------------------------------------------------------------
/Tests/t.go:
--------------------------------------------------------------------------------
1 | /*
2 | * this test a number of aspects of classes, and type inference
3 | */
4 | t{
5 | comp[a] <~ {
6 | less:[comp[a]]{}.
7 | eq:[comp[a]]{}
8 | }.
9 |
10 | tree[x<~comp[x]] <~ {
11 | insert:[x]=>tree[x]. /* ::sorted(this). insert::sorted(this)=>sorted(this). */
12 | }.
13 |
14 | nd:[tree[comp[T]],comp[T],tree[comp[T]]]@=tree[comp[T]].
15 | nd(L,B,R)..{
16 | insert(E)::E.eq(B) => this.
17 | insert(E)::E.less(B) => nd(L.insert(E),B,R).
18 | insert(E)::\+E.less(B) => nd(L,B,R.insert(E)).
19 | }.
20 | }
21 |
--------------------------------------------------------------------------------
/go.Make.in:
--------------------------------------------------------------------------------
1 | #
2 | # Rules for compiling go programs within the build tree
3 | #
4 | .SUFFIXES: .go .goc .gof .glx .gpg
5 |
6 | GO_DIR = file:///${top_builddir}/
7 | GOC = @aprildir@/bin/april -h30000 file:///${top_builddir}/BootCompiler/goc.aam
8 | GO = ${top_builddir}/Engine/go
9 |
10 | %.goc: ${srcdir}/%.go
11 | @echo Compiling go! program $<
12 | GO_DIR=$(GO_DIR) $(GOC) $(GOFLAGS) $<
13 |
14 | %.go: ${srcdir}/%.glx
15 | @echo generating tokeniser from $<
16 | GO_DIR=${top_builddir} $(GO) -h3000 -P ${top_builddir}/golex golex $(GOLEX_OPTS) $<
17 |
18 |
--------------------------------------------------------------------------------
/rdf/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Build the Go! RDF libraries
3 | #
4 | include ${top_builddir}/go.Make
5 |
6 | SUFFIXES = .af .ah .go .goc
7 |
8 | GO_SRCS = rdfstore.go n3.go
9 |
10 | GO_CODE = $(GO_SRCS:.go=.goc)
11 |
12 | EXTRA_DIST = ${GO_SRCS}
13 |
14 | CLEANFILES = ${GO_CODE} $(GO_SRCS:.go=.gof)
15 |
16 | n3.goc: rdfstore.goc
17 |
18 | all-local: ${GO_CODE}
19 |
20 | install-data-local: ${GO_CODE}
21 | -${top_srcdir}/mkinstalldirs $(DESTDIR)${prefix}/rdf
22 | (for XX in ${GO_CODE} ; do\
23 | $(INSTALL_SCRIPT) $${XX} $(DESTDIR)${prefix}/rdf; done)
24 |
--------------------------------------------------------------------------------
/Doc/QuickRef/quick.ilg:
--------------------------------------------------------------------------------
1 | This is makeindex, version 2.14 [02-Oct-2002] (kpathsea + Thai support).
2 | Scanning input file ./quick.idx....
3 | !! Input index error (file = ./quick.idx, line = 20):
4 | -- Illegal null field.
5 |
6 | !! Input index error (file = ./quick.idx, line = 52):
7 | -- Illegal null field.
8 | done (428 entries accepted, 2 rejected).
9 | Sorting entries......done (4178 comparisons).
10 | Generating output file ./quick.ind....done (527 lines written, 0 warnings).
11 | Output written in ./quick.ind.
12 | Transcript written in ./quick.ilg.
13 |
--------------------------------------------------------------------------------
/Tests/inherit.go:
--------------------------------------------------------------------------------
1 | inherit{
2 | import go.io.
3 | import go.dynamic.
4 |
5 |
6 |
7 | spr[T] <~ { beliefs:dynamic[T] }.
8 |
9 | sub[T] <~ { name:symbol, check:(T){}}.
10 |
11 | spr(I):spr[symbol]..{
12 | beliefs = $dynamic(I).
13 | }.
14 |
15 | sub(I) <= spr(I).
16 | sub(_):sub[symbol]..{
17 | name = 'myName'.
18 |
19 | check(O) :- beliefs.mem(O).
20 | }.
21 |
22 | main(_) ->
23 | OO = $sub(['me','you']);
24 | ( OO.check('me')?
25 | stdout.outLine("Ok")
26 | | stdout.outLine("not Ok")).
27 | }
28 |
--------------------------------------------------------------------------------
/dl/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Build the DL library
3 | #
4 |
5 | include ${top_builddir}/go.Make
6 |
7 | GO_SRCS = dl.go parse.go terms.go
8 | GO_CODE = $(GO_SRCS:.go=.goc) dllex.goc
9 | CLEANFILES = ${GO_CODE} $(GO_SRCS:.go=.gof)
10 |
11 | GOLEX_OPTS=-p dl.dllex
12 |
13 | parse.goc: terms.goc dllex.goc
14 |
15 | dl.goc: terms.goc parse.goc
16 |
17 | all-local: ${GO_CODE}
18 |
19 | install-data-local: ${GO_CODE}
20 | -${top_srcdir}/mkinstalldirs $(DESTDIR)${prefix}/dl
21 | (for XX in ${GO_CODE} ; do\
22 | $(INSTALL_SCRIPT) $${XX} $(DESTDIR)${prefix}/dl; done)
23 |
--------------------------------------------------------------------------------
/Tests/fact.xml:
--------------------------------------------------------------------------------
1 | xml version="1.0" ?>
2 |
5 | ]>
6 |
7 |
8 | <_>01
9 | <_>
10 |
11 |
12 |
13 |
14 | &foo;&&foo;
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/gpg/tokens.go:
--------------------------------------------------------------------------------
1 | /*
2 | * The token types for the GpG parser generator
3 | */
4 | gpg.tokens{
5 |
6 | assoc ::= leftA | rightA | nonA | tokenA.
7 |
8 | yyType ::= N(number)
9 | | I(string)
10 | | GPGRULESET(yyType,yyType)
11 | | SEQ(yyType,yyType)
12 | | TOKENSPEC(yyType)
13 | | OPERATORSPEC(yyType,assoc)
14 | | STARTSPEC(string)
15 | | EXPECTSPEC(integer)
16 | | APPLY(string,string)
17 | | TYPESPEC(string)
18 | | RULESET(string,yyType)
19 | | CHOICE(yyType,yyType)
20 | | RULE(yyType,yyType,yyType)
21 | | EMPTY.
22 |
23 | }
--------------------------------------------------------------------------------
/macros/htmldir.m4:
--------------------------------------------------------------------------------
1 | dnl NA_WITH_HTML
2 | dnl
3 | dnl Description:
4 | dnl Parse the --with-html option passed to configure to
5 | dnl set the html documentation installation directory.
6 | dnl
7 | dnl Defines
8 | dnl htmldir - html documentation installation directory
9 | dnl
10 | dnl Notes
11 | dnl Figure out where to put the html stuff
12 |
13 | AC_DEFUN(NA_WITH_HTMLDIR,[
14 |
15 | AC_ARG_WITH(htmldir,
16 | [ --with-html[=PREFIX/html] indicate location of the html dir],
17 | [htmldir=${withval}],
18 | [htmldir='${prefix}/html'])
19 |
20 | AC_SUBST(htmldir)
21 |
22 | ])
--------------------------------------------------------------------------------
/Tests/dyntest.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test filtered lists
3 | */
4 |
5 | dyntest{
6 | import go.dynamic.
7 | import go.io.
8 |
9 | tree[_A] ::= empty | node(tree[_A],_A,tree[_A]).
10 |
11 | -- tree[A] <~ {}.
12 |
13 | -- empty:tree[A] .. {}.
14 |
15 | -- node(_1:tree[A],_2:A,_3:tree[A]):tree[A]..{}.
16 |
17 | main(_) ->
18 | D = $dynamic([empty,node(empty,'a',empty),node(node(empty,'a',empty),'b',empty),node(empty,'a',node(empty,'b',empty))]);
19 | stdout.outLine(D.ext().show());
20 | (D.mem(node(_,Lb,empty)) *> stdout.outLine(Lb.show())).
21 | }
22 |
--------------------------------------------------------------------------------
/BootCompiler/april.Make:
--------------------------------------------------------------------------------
1 | #
2 | # Rules for compiling april programs within the build tree
3 | #
4 | APRILDIR = file:////opt/april
5 | APC = /opt/april/bin/apc
6 | APRIL_PREAMBLE="\#!/opt/april/bin/april -C- -p$(GO_DIR)/BootCompiler $(APRIL_EXEC_FLAGS)"
7 |
8 | %.aam: ${srcdir}/%.ap
9 | APRIL_DIR=$(APRILDIR) $(APC) $(APCFLAGS) -o $(basename $@).aam $<
10 |
11 | %: ${srcdir}/%.ap
12 | APRIL_DIR=$(APRILDIR) APRIL_PREAMBLE=$(APRIL_PREAMBLE) $(APC) $(APCFLAGS) -o ${basename $@} -x $<
13 |
14 | %.af: ${srcdir}/%.ap
15 | APRIL_DIR=$(APRILDIR) $(APC) $(APCFLAGS) -M -o $(basename $@).aam $<
16 |
--------------------------------------------------------------------------------
/BootCompiler/april.Make.in:
--------------------------------------------------------------------------------
1 | #
2 | # Rules for compiling april programs within the build tree
3 | #
4 | APRILDIR = file:///@aprildir@
5 | APC = @aprildir@/bin/apc
6 | APRIL_PREAMBLE="\#!@aprildir@/bin/april -C- -p$(GO_DIR)/BootCompiler $(APRIL_EXEC_FLAGS)"
7 |
8 | %.aam: ${srcdir}/%.ap
9 | APRIL_DIR=$(APRILDIR) $(APC) $(APCFLAGS) -o $(basename $@).aam $<
10 |
11 | %: ${srcdir}/%.ap
12 | APRIL_DIR=$(APRILDIR) APRIL_PREAMBLE=$(APRIL_PREAMBLE) $(APC) $(APCFLAGS) -o ${basename $@} -x $<
13 |
14 | %.af: ${srcdir}/%.ap
15 | APRIL_DIR=$(APRILDIR) $(APC) $(APCFLAGS) -M -o $(basename $@).aam $<
16 |
--------------------------------------------------------------------------------
/Tests/palin.go:
--------------------------------------------------------------------------------
1 | palin{
2 | import go.io.
3 | import go.unit.
4 |
5 | private palin:[string]-->string.
6 |
7 | palin([C,..L]) --> [C], palin(L), [C].
8 | palin([C]) --> [C].
9 | palin([]) --> [].
10 |
11 | testpalin:[string]@=harness.
12 | testpalin(_)<=harness.
13 | testpalin(T)..{
14 | doAction() ->
15 | ((palin(X)-->T) ?
16 | stdout.outLine("Parsed "<>T<>" is "<>X)
17 | | stdout.outLine(T<>" does not seem to be palindromic")).
18 | }.
19 |
20 | main([]) -> checkUnit(testpalin("go2002og")).
21 | main([T]) -> checkUnit(testpalin(T)).
22 | }
--------------------------------------------------------------------------------
/Tests/expand.go:
--------------------------------------------------------------------------------
1 | expand{
2 | import go.io.
3 | import go.unit.
4 | import go.setlib.
5 |
6 |
7 | expandTest:[]@=harness.
8 | expandTest<=harness.
9 | expandTest..{
10 | doPred() :-
11 | expand("this is a list of words"," ") = ["this","is","a","list","of","words"],
12 | Sent = "this is a list of words",
13 | collapse(expand(Sent," ")," ")=Sent.
14 | doAction() ->
15 | stdout.outLine(expand("this is a list of words "," ").show());
16 | stdout.outLine(collapse(expand("this is a list of words "," ")," ")).
17 | }.
18 |
19 | main(_) ->
20 | checkUnit(expandTest).
21 | }
--------------------------------------------------------------------------------
/Tests/race.go:
--------------------------------------------------------------------------------
1 | race{
2 | -- This is a little race - between threads
3 | import go.io.
4 | import go.stdparse.
5 |
6 | racer:[integer]*.
7 | racer(0)->{}.
8 | racer(N)::N rem 1000 == 0.0 ->
9 | stdout.outLine(__thread().show()<>" at "<>N.show());
10 | racer(N-1).
11 | racer(N) ->
12 | racer(N-1).
13 |
14 | main([N,C,.._]) ->
15 | NN = naturalOf%%N;
16 | CC = naturalOf%%C;
17 | ( T in { spawn{racer(NN)} .. _ in iota(1,CC) } *>
18 | waitfor(T) );
19 | stdout.outLine("That was fun!").
20 | main([]) ->
21 | main(["100000","100"]).
22 | }
--------------------------------------------------------------------------------
/Tests/constraints.go:
--------------------------------------------------------------------------------
1 | constraints{
2 |
3 | import go.io.
4 |
5 | constraints:[integer,integer]{}.
6 | constraints(X,Y) :-
7 | (Y@@Y>3)=Y1,
8 | (X@@XY.show())},
11 | X1 in [4,3,2,1],
12 | action{stdout.outLine("X= "<>X.show())}.
13 |
14 | -- main(_) -> (constraints(X,Y) *> stdout.outLine("Results, X is "<>X.show()<>" Y is "<>Y.show())).
15 | main(_) -> (constraints(X,Y) *> stdout.outLine("Result are "<>(X,Y).show())).
16 | -- main(_) -> stdout.outLine("Tuple "<>(2,3).show()).
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/Tests/onemsg.go:
--------------------------------------------------------------------------------
1 | onemsg{
2 | import go.io.
3 | import go.unit.
4 | import go.mbox.
5 |
6 | onemsg:[]@=harness.
7 | onemsg<=harness.
8 | onemsg..{
9 | doAction() ->
10 | H = mailbox();
11 | T = spawn {echo(H)};
12 | ping(H.dropbox());
13 | waitfor(T).
14 |
15 | echo:[mailbox[string]]*.
16 | echo(Mbx) ->
17 | case Mbx.next() in (
18 | Msg -> stdout.outLine(Msg)
19 | ).
20 |
21 | ping:[dropbox[string]]*.
22 | ping(T) ->
23 | T.post("Hello").
24 | }.
25 |
26 | main(_) ->
27 | checkUnit(onemsg).
28 | }.
--------------------------------------------------------------------------------
/Tests/p.go:
--------------------------------------------------------------------------------
1 | /*
2 | * A simple module implementing a person class
3 | */
4 |
5 | p{
6 | person <~ { name:[]=>string}.
7 |
8 | person:[string,person]@=person.
9 | person(Name,Sp)..{
10 | name()=>Name.
11 | show() => Name<>" married to "<>Sp.show().
12 | }.
13 |
14 | school <~ {}.
15 |
16 | student <~ { school:[]=>school }.
17 | student <~ person.
18 |
19 | student:[string,school,person]@=student.
20 | student(Name,_,P) <= person(Name,P).
21 | student(_,School,_)..{
22 | school()=>School.
23 | show()=>person.show()<>" studying at "<>School.show()
24 | }.
25 | }
26 |
--------------------------------------------------------------------------------
/Tests/rdftest.go:
--------------------------------------------------------------------------------
1 | rdftest{
2 | import go.io.
3 | import go.unit.
4 | import go.rdfstore.
5 |
6 | rdftest:[]@=harness.
7 | rdftest<=harness.
8 | rdftest..{
9 | doAction() ->
10 | R = $rdfstore;
11 | R.put(rdf('s1','v','o'));
12 | R.put(rdf('s1','v','o2'));
13 | R.put(rdf('s2','v','o'));
14 | R.put(rdf('s2','v1','o1'));
15 | R.put(rdf('o2','v','o2'));
16 | ( R.query([rdf(S,V,O),rdf(O,V,O1)]) *>
17 | stdout.outLine(S.show()<>" leads to "<>O1.show()));
18 | stdout.outLine(R.ext().show());
19 | stdout.outLine(R.show()).
20 | }.
21 |
22 | main(_) ->
23 | checkUnit(rdftest).
24 | }
--------------------------------------------------------------------------------
/Tests/sortmain.go:
--------------------------------------------------------------------------------
1 | sortmain{
2 | import sorting.
3 | import go.io.
4 |
5 | sortIntegers:[list[integer]] => list[integer].
6 | sortIntegers(L) => sort(L, :compare[integer] .. { less(X,Y) :- X=J.
12 | show() => "("<>K.show()<>")".
13 | }.
14 |
15 | main(_) ->
16 | stdout.outLine("Sort of [1,3,5,2,0,10] is "<>
17 | sortIntegers([1,3,5,2,0,10]).show());
18 | stdout.outLine("Quick sort of [1,3,5,2,0,10] is "<>
19 | quick({I(X)..X in [1,3,5,2,0,10]}).show());
20 | }
21 |
--------------------------------------------------------------------------------
/gpg/abstract.go:
--------------------------------------------------------------------------------
1 | /*
2 | * The abstract parse types for the GpG parser generator
3 | */
4 | gpg.abstract{
5 |
6 | assoc ::= leftA | rightA | nonA | tokenA.
7 |
8 | yyType ::= N(number)
9 | | I(string)
10 | | GPGRULESET(yyType,yyType)
11 | | SEQ(yyType,yyType)
12 | | TOKENSPEC(yyType)
13 | | OPERATORSPEC(yyType,assoc)
14 | | STARTSPEC(string)
15 | | LEXERSPEC(string)
16 | | EXPECTSPEC(integer)
17 | | APPLY(string,string)
18 | | TYPESPEC(string)
19 | | RULESET(string,yyType)
20 | | CHOICE(yyType,yyType)
21 | | RULE(yyType,yyType,yyType)
22 | | EMPTY.
23 |
24 | }
--------------------------------------------------------------------------------
/Tests/shell.go:
--------------------------------------------------------------------------------
1 | shell{
2 | import go.io.
3 | import go.unit.
4 |
5 | shell:[string,string]@=harness.
6 | shell(_,_)<=harness.
7 | shell(Cmd,Arg1)..{
8 | doAction() ->
9 | stdout.outLine("doing "<>Cmd);
10 | (_,o,e) = pipeConnect(Cmd,[Arg1],[],utf8Encoding);
11 | consume(o);
12 | consume(e).
13 | }.
14 |
15 | consume:[inChannel]*.
16 | consume(i)::i.eof()->{}.
17 | consume(i)->stdout.outLine(i.inLine("\n")); consume(i).
18 |
19 | main([]) ->
20 | checkUnit(shell("/bin/ls",fcwd())).
21 | main([Cmd,Arg]) ->
22 | checkUnit(shell(Cmd,Arg)).
23 | }
24 |
--------------------------------------------------------------------------------
/Tests/spawn.go:
--------------------------------------------------------------------------------
1 | spawn{
2 | import go.io.
3 | import go.stdparse.
4 |
5 | sleepForEver:[]*.
6 | sleepForEver() ->
7 | stdout.outLine("Hello, world.");
8 | delay(1);
9 | sleepForEver().
10 |
11 | sleepSome:[integer]*.
12 | sleepSome(T) ->
13 | delay(T);
14 | stdout.outLine(__thread().show()<>"done sleeping").
15 |
16 | spawnMany:[integer]*.
17 | spawnMany(C) ->
18 | P in reverse({ spawn{sleepSome(N)} .. N in iota(1,C) }) *>
19 | ( stdout.outLine("waiting for "<>P.show());waitfor(P)).
20 |
21 | main([C,.._]) ->
22 | spawnMany(naturalOf%%C).
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/Tests/surgery.dl:
--------------------------------------------------------------------------------
1 | -- The surgery ontology example
2 | -- First example of Go's ontology DL language
3 | surgery{
4 | import "individuals.dl".
5 |
6 | Doctor <= thing.
7 |
8 | Specialist == Doctor && #specialty.
9 |
10 | AmericanSpecialist == Specialist && country=america.
11 |
12 | AmericanDermatologist == AmericanSpecialist && specialty=dermatology.
13 |
14 | AmericanSurgeon == AmericanSpecialist && specialty=surgery.
15 |
16 | Surgeon == Doctor && specialty=surgery.
17 |
18 | Dermatologist == Doctor && specialty=dermatology.
19 |
20 | Specialty == { surgery, dermatology}.
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/Tests/telnet.go:
--------------------------------------------------------------------------------
1 | /* A simple telnet-like program */
2 |
3 | telnet{
4 | import go.io.
5 | import go.stdparse.
6 |
7 | main([H,P]) ->
8 | tcpConnect(H,naturalOf%%P,i,o,utf8Encoding);
9 | spawn {reader(i)};
10 | readKeyStrokes(o);
11 | stdout.outLine("End").
12 |
13 | reader:[inChannel]*.
14 | reader(i)::i.eof() -> {}.
15 | reader(i) ->
16 | stdout.outLine(i.inLine("\n"));
17 | reader(i).
18 |
19 | readKeyStrokes:[outChannel]*.
20 | readKeyStrokes(_)::stdin.eof() -> {}.
21 | readKeyStrokes(o) ->
22 | o.outCh(stdin.inCh());
23 | readKeyStrokes(o).
24 | }.
--------------------------------------------------------------------------------
/Tests/basicwin.go:
--------------------------------------------------------------------------------
1 | -- A test of the widget library
2 | basicwin{
3 | import go.io.
4 | import graph.widget.
5 | import graph.xlabel.
6 | import graph.xlib.
7 |
8 | main([]) ->
9 | W = window(0.0,0.0,200.0,100.0,"A trial balloon");
10 | W.add(gLabel("Hello world",font("-adobe-courier-*-r-*-*-14-*-*-*-*-*-*-*",14.0),W));
11 | W.add(gLabel("Again",font("-adobe-courier-*-r-*-*-14-*-*-*-*-*-*-*",14.0),W));
12 | W.add(gLabel("And again",font("-*-helvetica-*-r-*-*-14-*-*-*-*-*-*-*",14.0),W));
13 | -- W.add(gLabel("Hello world",font("9x15",14.0),W));
14 | W.realize();
15 | processEvents().
16 | }
--------------------------------------------------------------------------------
/Tests/files.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test some of the file and directory handling stuff
3 | */
4 | files{
5 | import go.io.
6 | import go.unit.
7 |
8 | files:[]@=harness.
9 | files<=harness.
10 | files..{
11 | doAction() ->
12 | CWD = fcwd();
13 | stdout.outLine("Current directory = "<>CWD);
14 | (F in fls(fcwd()) *>
15 | stdout.outLine(F));
16 | fcd("..");
17 | stdout.outLine("Current directory is now "<>fcwd());
18 | fcd(CWD);
19 | stdout.outLine("Current directory is now "<>fcwd()).
20 | }.
21 |
22 | main(_) ->
23 | checkUnit(files).
24 | }
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Engine/Headers/term.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Header file giving the interface for reading and writing terms
3 | */
4 | #ifndef _TERM_H_
5 | #define _TERM_H_
6 |
7 | retCode outCell(ioPo f,ptrPo x,long depth,long prec,logical alt);
8 | retCode outType(ioPo f,ptrPo x,long depth,long prec,logical alt);
9 | retCode decodeTerm(ioPo in,heapPo P,heapPo R,ptrPo tgt,uniChar *errorMsg,long msgSize);
10 | retCode skipEncoded(ioPo in,uniChar *errorMsg, long msgLen);
11 |
12 | retCode quoteString(ioPo f,uniChar *s,long len);
13 | retCode outXML(ioPo f,ptrPo x,long depth,long prec,logical alt) ;
14 | retCode xmlQuoteString(ioPo f,uniChar *s,long len);
15 | #endif
16 |
--------------------------------------------------------------------------------
/Tests/meta.go:
--------------------------------------------------------------------------------
1 | meta{
2 | import go.io.
3 | import go.unit.
4 | import person.
5 |
6 | metaTest:[]@=harness.
7 | metaTest<=harness.
8 | metaTest..{
9 | doAction() ->
10 | -- S = student("Fred", imperial, noone);
11 | S = %["23"]%;
12 | stdout.outLine(__stringOf(X,0,0));
13 | V = %[X]%;
14 | stdout.outLine(__stringOf(S,0,0));
15 | stdout.outLine(S.show());
16 | stdout.outLine(__stringOf(V,0,0));
17 | stdout.outLine(V.show());
18 | X = [23];
19 | Y = X._meta();
20 | stdout.outLine(__stringOf(Y,0,0));
21 | stdout.outLine(Y.show()) .
22 | }.
23 |
24 | main(_) ->
25 | checkUnit(metaTest).
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/go/app.go:
--------------------------------------------------------------------------------
1 | app{
2 | /*
3 | []:list[_]..{
4 | eof().
5 | cons(_,_) :- false.
6 | show() => "[]".
7 | head() => [].
8 | tail() => [].
9 | eq([]).
10 | }.
11 | */
12 |
13 | [H:t,..T]:list[t]..{
14 | eof() :- false.
15 | cons(H,T).
16 | show() => "["<>showList([H,..T],"")<>"]".
17 | head()=>H.
18 | tail()=>T.
19 | eq([H,..T]).
20 |
21 | showList([],_)=>[].
22 | showList([El,..R],Sep) => Sep<>El^0<>showList(R,",").
23 |
24 | -- []<>X=>X.
25 | -- [E,..X]<>Y=>[E,..X<>Y].
26 | }.
27 |
28 | (<>):[t]-((list[t],list[t])=>list[t]).
29 | []<>X=>X.
30 | [E,..X]<>Y=>[E,..X<>Y].
31 | }
--------------------------------------------------------------------------------
/Tests/date.go:
--------------------------------------------------------------------------------
1 | /* Test the various date & time functions */
2 |
3 | date{
4 | import go.io.
5 | import go.datelib.
6 |
7 | main([A]) ->
8 | N = now();
9 | D = time2date(N);
10 | stdout.outLine("Time is "<>N^0<>" date = "<>D.show());
11 | U = time2utc(N);
12 | stdout.outLine("UTC equivalent = "<>U.show());
13 | stdout.outLine("Converted back = "<>D.time()^0);
14 | stdout.outLine("Converted back (UTC) = "<>U.time()^0);
15 | ( (rfc822_date(R)-->A) ?
16 | stdout.outLine("Parsed argument is "<>R.show())
17 | | stdout.outLine("Couldn't parse "<>A)
18 | ).
19 | }
20 |
21 |
22 |
--------------------------------------------------------------------------------
/mysql/go/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Build the mysql Go! libraries
3 | #
4 | include ${top_builddir}/go.Make
5 |
6 | SUFFIXES = .af .ah .go .gof .goc
7 |
8 | GOFLAGS = -dest ext/mysql/go
9 |
10 | GO_SRCS = mysql.go
11 |
12 | GOF_FILES = $(GO_SRCS:.go=.gof)
13 | GO_CODE = $(GO_SRCS:.go=.goc)
14 |
15 | EXTRA_DIST = ${GO_SRCS}
16 |
17 | CLEANFILES = ${GO_CODE} ${GOF_FILES}
18 |
19 | all-local: ${GO_CODE} ${GOF_FILES}
20 |
21 | install-data-local: ${GO_CODE} ${GOF_FILES}
22 | -${top_srcdir}/mkinstalldirs ${prefix}/ext/mysql/go
23 | (for XX in ${GOF_FILES} ${GO_CODE}; do\
24 | $(INSTALL_SCRIPT) $${XX} ${prefix}/ext/mysql/go; done)
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/BootCompiler/xtree.ah:
--------------------------------------------------------------------------------
1 | /*
2 | * Type definition for the and/or tree used in the decision tree analyser
3 | */
4 | elType ::=
5 | sy(string) -- The symbol case
6 | | nm(number) -- The number case
7 | | c(char) -- The char case
8 | | ls -- The list casee
9 | | fn(string,number) -- The constructor case, fun sym, arity
10 | | oth((canonTree,number)[]) -- Other kind of term
11 | | leaf(number) -- End of the list
12 | ;
13 |
14 | xTr ::= empty -- null tree
15 | | tX(elType,logical,xTr,xTr) -- the node label, match, choice, the rest
16 | ;
17 |
18 |
--------------------------------------------------------------------------------
/BootCompiler/comp.ah:
--------------------------------------------------------------------------------
1 | /*
2 | * Code generation structures
3 | */
4 | vOcc ::= hArg | hTerm | oArg | oTerm | lArg | lTerm ;
5 |
6 | sourceType ::= notAlloc | voidVar | aReg(number) | yReg(number,logical) | sReg;
7 |
8 | dEntry ::= de(string,
9 | (()=>logical), -- currently inited?
10 | (logical){}, -- initialize it
11 | (()=>logical), -- defined?
12 | (logical){}, -- define it
13 | (()=>sourceType),
14 | (sourceType){},
15 | number[][]);
16 |
17 | isGroundTypeFlag ::= isGrnd | notGrnd;
18 |
19 | usedFlags ::= usdRgs(number[],number[],number[],number,number);
20 |
21 |
--------------------------------------------------------------------------------
/mysql/Tests/test.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test the mysql interface
3 | */
4 |
5 | main..{
6 | include "sys:go/io.gof".
7 | include "sys:go/stdlib.gof".
8 | include "sys:ext/mysql/include/libmysqlgo.gof".
9 |
10 | main() ->
11 | Q =__mysql_query("localhost","root","","test","select * from foo");
12 | N = __mysql_numrows(Q);
13 | F = __mysql_fetchfields(Q);
14 | stdout.outLine("Q="<>Q^0);
15 | stdout.outLine("N="<>N^0);
16 | stdout.outLine("F="<>F^0);
17 | fetchRows(Q).
18 |
19 | fetchRows(Q)::__mysql_fetchrow(Q,R) ->
20 | stdout.outLine("Row= "<>R^0);
21 | fetchRows(Q).
22 | fetchRows(_) -> {}.
23 | }
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Tests/valtest.go:
--------------------------------------------------------------------------------
1 | valtest{
2 | import go.io.
3 | import go.unit.
4 |
5 | -- Test some features of action/istrue
6 |
7 | val:[symbol]{}.
8 | val(k) :-
9 | action{
10 | stdout.outLine("Trying Ok route");
11 | istrue k=='Ok';
12 | stdout.outLine("Exiting k= "<>k.show())
13 | }.
14 |
15 | testval:[symbol]@=harness.
16 | testval(_)<=harness.
17 | testval(Ok)..{
18 | doPred() :-
19 | val(Ok).
20 | doPred() :-
21 | action{
22 | stdout.outLine("doPred failed, as expected")
23 | }.
24 | }.
25 |
26 | main([]) ->
27 | checkUnit(testval('Ok'));
28 | checkUnit(testval('not Ok'))
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/Engine/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile.am to create the go engine
3 | #
4 | SUBDIRS = Headers
5 |
6 | bin_PROGRAMS = go
7 |
8 | go_SOURCES = main.c boot.c eval.c stats.c process.c suspend.c clock.c date.c \
9 | heap.c global.c gc.c float.c list.c string.c \
10 | dict.c escapes.c verify.c\
11 | exec.c signal.c error.c debug.c \
12 | args.c arith.c encoded.c writef.c misc.c\
13 | char.c fileio.c tcp.c dir.c envir.c put.c\
14 | program.c code.c \
15 | hashtable.c dynamic.c lockvar.c class.c call.c sha.c
16 |
17 | INCLUDES = -I@top_srcdir@/Engine/Headers -I@top_srcdir@/Headers -I@ooiodir@/include '-DGODIR="@prefix@"'
18 | go_LDFLAGS = @go_LDFLAGS@
19 | go_LDADD = @ooiodir@/lib/libooio.la
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Tests/env.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test the environment variables stuff
3 | */
4 |
5 | env{
6 | import go.unit.
7 | import go.io.
8 |
9 | showEnv:[list[(symbol,string)]]*.
10 | showEnv([]) -> {}.
11 | showEnv([(K,V),..L]) -> stdout.outLine(K.show()<>":"<>V);
12 | showEnv(L).
13 |
14 | envtest:[]@=harness.
15 | envtest<=harness.
16 | envtest..{
17 | doAction() ->
18 | showEnv(envir());
19 | stdout.outLine("USER="<>getenv('USER',"not found"));
20 | {setenv('myKey',"This is an environment var")};
21 | stdout.outLine("myKey="<>getenv('myKey',"not found"));
22 | showEnv(envir()).
23 | }.
24 |
25 | main(_) ->
26 | checkUnit(envtest);
27 | }
28 |
--------------------------------------------------------------------------------
/Engine/Headers/dict.h:
--------------------------------------------------------------------------------
1 | /*
2 | Public declarations for the dictionary functions for April
3 | */
4 | #ifndef _DICT_H_
5 | #define _DICT_H_
6 |
7 | void initSymbolClass(void);
8 | void initDict(); /* Initialize the dictionary */
9 |
10 | ptrI newSymbol(const char *name);
11 | ptrI newEnumSym(const char *name);
12 | ptrI newUniSymbol(const uniChar *name);
13 | ptrI newEnumSymbol(const uniChar *name);
14 | ptrI symbolPresent(uniChar *s);
15 |
16 | void installSymbol(symbPo s);
17 | funpo getescape(symbPo l); /* Get an escape code */
18 | char *escapeName(int code);
19 | funpo escapeCode(unsigned int code);
20 |
21 | void install_escapes(void);
22 |
23 | void restartDictionary(globalGcPo G);
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/Tests/code.go:
--------------------------------------------------------------------------------
1 | code{
2 | import go.io.
3 | import go.stdparse.
4 | import tree.
5 |
6 | -- Test the code generation functionality
7 |
8 | test:[]*.
9 | test() ->
10 | T = [(1,2),_,(3,X),(4,X)];
11 | stdout.outLine("T = "<>T.show());
12 | TT = __term(T);
13 | stdout.outLine("TT = "<>TT.show());
14 | {__is(TT,M)};
15 | stdout.outLine("*TT = "<>M.show());
16 | OO = $T;
17 | stdout.outLine("OO = "<>__stringOf(OO,0,0));
18 | stdout.outLine("*OO = "<>OO.show()).
19 |
20 | emm:[]@=tree[comp[_]].
21 | emm..{
22 | show()=>"*".
23 | insert(a) => nd(em,a,em).
24 | empty().
25 | }.
26 |
27 | main(_) ->
28 | test().
29 | }
30 |
31 |
32 |
--------------------------------------------------------------------------------
/BootCompiler/app.go:
--------------------------------------------------------------------------------
1 | app{
2 | -- implement the list interface for lists
3 | []:list[_]..{
4 | eof().
5 | cons(X) => [X].
6 | tack(X) => [X].
7 | hdtl(_,_) :- false.
8 | display(W,_) => __trim("[]",W).
9 | show() => "[]".
10 | head() => _.
11 | tail() => this.
12 | eq([]).
13 | }.
14 |
15 | [H:t,..T:list[t]]:list[t]..{
16 | eof() :- false.
17 | hdtl(H,T).
18 | cons(X) => [X,..this].
19 |
20 | display(W,_) => "".
21 |
22 | show() => "".
23 |
24 | head()=>H.
25 | tail()=>T.
26 |
27 | tack(X) => this<>[X].
28 | eq([H,..T]).
29 | }.
30 |
31 | (<>):(list[t],list[t])=>list[t].
32 |
33 | [] <> X => X.
34 | [E,..X] <> Y => [E,..X<>Y].
35 | }
--------------------------------------------------------------------------------
/Tests/negtest.go:
--------------------------------------------------------------------------------
1 | negtest{
2 |
3 | import go.io.
4 |
5 | testnum:integer := 0.
6 |
7 | main(_) ->
8 | testnum := -128;
9 | stdout.outLine( "Test integer (-128) = "<>testnum.show() );
10 |
11 | testnum := -129;
12 | stdout.outLine( "Test integer (-129) = "<>testnum.show() );
13 |
14 | testnum := -200;
15 | stdout.outLine( "Test integer (-200) = "<>testnum.show() );
16 |
17 | testnum := -256;
18 | stdout.outLine( "Test integer (-256) = "<>testnum.show() );
19 |
20 | testnum := -257;
21 | stdout.outLine( "Test integer (-257) = "<>testnum.show() );
22 |
23 | testnum := 200 * -1;
24 | stdout.outLine( "Test integer (200*-1) = "<>testnum.show() ).
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/Doc/go-ref.ilg:
--------------------------------------------------------------------------------
1 | This is makeindex, version 2.14 [02-Oct-2002] (kpathsea + Thai support).
2 | Scanning input file ./go-ref.idx....
3 | !! Input index error (file = ./go-ref.idx, line = 25):
4 | -- Illegal null field.
5 |
6 | !! Input index error (file = ./go-ref.idx, line = 60):
7 | -- Illegal null field.
8 | done (478 entries accepted, 2 rejected).
9 | Sorting entries.......done (4587 comparisons).
10 | Generating output file ./go-ref.ind....
11 | ## Warning (input = ./go-ref.idx, line = 116; output = ./go-ref.ind, line = 357):
12 | -- Conflicting entries: multiple encaps for the same page under same key.
13 | done (575 lines written, 1 warning).
14 | Output written in ./go-ref.ind.
15 | Transcript written in ./go-ref.ilg.
16 |
--------------------------------------------------------------------------------
/Tests/ul.y:
--------------------------------------------------------------------------------
1 | /*
2 | * Grammar file for UL
3 | */
4 |
5 | %token ID INT SEMI EQUAL PRINT HALT LPAR RPAR
6 | %left PLUS MINUS
7 | %left STAR SLASH
8 | %nonassoc UMINUS
9 | %start program
10 |
11 | %%
12 |
13 | program : statements ;
14 |
15 | statements : statements statement
16 | | statement
17 | ;
18 |
19 | statement : assignment
20 | | print
21 | | halt
22 | ;
23 |
24 | assignment : ID EQUAL exp SEMI
25 | ;
26 |
27 | print : PRINT exp SEMI
28 | ;
29 |
30 | halt : HALT SEMI
31 | ;
32 |
33 | exp : ID
34 | | INT
35 | | exp PLUS exp
36 | | exp MINUS exp
37 | | exp STAR exp
38 | | exp SLASH exp
39 | | MINUS exp %prec UMINUS
40 | | LPAR exp RPAR
41 | ;
42 |
43 |
--------------------------------------------------------------------------------
/Tests/ifexp.go:
--------------------------------------------------------------------------------
1 | /*
2 | * A test of the conditional expression
3 | */
4 | ifexp{
5 | import go.io.
6 | import go.unit.
7 |
8 |
9 | ifFun:[integer]=>symbol.
10 | ifFun(A)::C=3 => ( A==1 ?
11 | 'a'
12 | | A==2?
13 | 'b'
14 | | A==C?
15 | 'c'
16 | | 'd').
17 |
18 | ifexp:[]@=harness.
19 | ifexp<=harness.
20 | ifexp..{
21 | doAction() ->
22 | stdout.outLine("ifFun(1)= "<>ifFun(1)^);
23 | stdout.outLine("ifFun(2)= "<>ifFun(2)^);
24 | stdout.outLine("ifFun(3)= "<>ifFun(3)^);
25 | stdout.outLine("ifFun(0)= "<>ifFun(0)^).
26 | }.
27 |
28 | main(_) ->
29 | checkUnit(ifexp).
30 | }
31 |
--------------------------------------------------------------------------------
/Tests/bagcheck.go:
--------------------------------------------------------------------------------
1 | bagcheck{
2 | import go.io.
3 |
4 | person:[symbol]{}.
5 | person('a').
6 | person('b').
7 | person('c').
8 | person('d').
9 | person('e').
10 |
11 | parent:[symbol,symbol]{}.
12 | parent('a','b').
13 | parent('a','c').
14 | parent(_,'b').
15 | parent('d','c').
16 |
17 | allPeople:[]=>list[symbol].
18 | allPeople() => { X || person(X) }.
19 |
20 | parentsOf:[symbol]=>list[symbol].
21 | parentsOf(X) => { P || parent(P,X) }.
22 |
23 | main(_) ->
24 | stdout.outLine("Everyone is "<>allPeople().show());
25 | stdout.outLine("parents of 'b' are "<>parentsOf('b').show());
26 | stdout.outLine("everyone's parents are "<>{ (X,parentsOf(X)) || person(X) }.show()).
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/mysql/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Make the mysql plugin for Go!
3 | #
4 |
5 | include ${top_builddir}/go.Make
6 |
7 | SUFIXES = .go .goc
8 |
9 | GO_SRC = misc.go packet.go session.go errors.go parse.go sqltypes.go
10 |
11 | misc.goc: packet.goc
12 |
13 | mysql.goc: sqltypes.goc parse.goc packet.goc misc.goc
14 |
15 | packet.goc: sqltypes.goc
16 |
17 | parse.goc: sqltypes.goc
18 |
19 | session.goc: misc.goc packet.goc sqltypes.goc
20 |
21 | GO_CODE=$(GO_SRC:.go=.goc)
22 |
23 | CLEANFILES = ${GO_CODE} $(GO_SRCS:.go=.gof)
24 |
25 | all-local: ${GO_CODE}
26 |
27 | install-data-local: ${GO_CODE}
28 | -${top_srcdir}/mkinstalldirs $(DESTDIR)${prefix}/go/mysql
29 | (for XX in ${GOC_FILES} ; do\
30 | $(INSTALL_SCRIPT) $${XX} ${prefix}/go/mysql; done)
31 |
--------------------------------------------------------------------------------
/BootCompiler/dynamic.ap:
--------------------------------------------------------------------------------
1 | /*
2 | * A dynamic set-like entity that can record a named set of values
3 | */
4 |
5 | #include "go.ah";
6 |
7 | module
8 | import interface in
9 | {
10 | dynQ(Init) => let {
11 | I : Init;
12 |
13 | query(N) => {
14 | if (N,X) in I then
15 | X
16 | else
17 | exception error(N^0<>" not defined",'fail)
18 | };
19 |
20 | define(N,V){
21 | if (N,_) in I then
22 | exception error(N^0<>"defined twice",'fail)
23 | else{
24 | I := [(N,V),..I]
25 | }
26 | };
27 |
28 | clear(N){
29 | if (N,_) in I then
30 | I := I^\(N,_)
31 | };
32 |
33 | defined() => I;
34 |
35 | } in dyn(query,define,clear,defined);
36 | } export dynQ
--------------------------------------------------------------------------------
/Tests/queuetest.go:
--------------------------------------------------------------------------------
1 | queuetest{
2 | import go.io.
3 | import go.queue.
4 | import go.unit.
5 |
6 | test:[]@>harness.
7 | test<=harness.
8 | test..{
9 | doPred() :-
10 | Q = queue([]),
11 | action{
12 | Q.push(34);
13 | Q.depth()==1;
14 | }.
15 |
16 | doAction() ->
17 | Q = queue([]);
18 | stdout.outLine(Q.show());
19 | Q.push(34);
20 | stdout.outLine(Q.show());
21 | Q.push(23);
22 | stdout.outLine(Q.show());
23 | Q.pull(E);
24 | stdout.outLine("Element pulled: "<>E^0);
25 | stdout.outLine(Q.show());
26 | stdout.outLine("Queue depth = "<>Q.depth()^0).
27 | }.
28 |
29 |
30 | main(_) ->
31 | checkUnit(test).
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/Tests/sorting.go:
--------------------------------------------------------------------------------
1 | sorting{
2 | compare[t] <~ { less:[t,t]{} }.
3 |
4 | sort:[list[t],compare[t]]=>list[t].
5 | sort([],_) => [].
6 | sort([E,..L], O)::split(L,E,O,A,B) => app(sort(A,O),[E,..sort(B,O)]).
7 |
8 | private split:[list[t]+,t+,compare[t],list[t]-,list[t]-]{}.
9 | split([],_,_,[],[]).
10 | split([E,..L],K,O,[E,..A],B) :- O.less(E,K), split(L,K,O,A,B).
11 | split([E,..L],K,O,A,[E,..B]) :- \+O.less(E,K), split(L,K,O,A,B).
12 |
13 | app:[list[t],list[t]]=>list[t].
14 | app([],X) => X.
15 | app([E,..A],X) => [E,..app(A,X)].
16 |
17 | cmp[t] <~ { lt:[cmp[t]]{}. ge:[cmp[t]]{} }.
18 |
19 | quick:[list[cmp[t]]]=>list[cmp[t]].
20 | quick([])=>[].
21 | quick([E,..L]) =>
22 | quick({X..(X@lt(E)) in L})<>[E,..quick({X..(X@ge(E)) in L})].
23 | }
24 |
--------------------------------------------------------------------------------
/BootCompiler/go.ah:
--------------------------------------------------------------------------------
1 |
2 | #include "go_tok.ah";
3 | #include "terms.ah";
4 | #include "canon.ah";
5 | #include "comp.ah";
6 |
7 | compOpt ::= noCodeGen | wffOnly | typeCheckOnly | noMeta | genGOF
8 | | sysGOF(string) | decOpt
9 | | classPath(string[]) | noStdLib | version(string)
10 | | bootOpt | showCanon | dbgComp | dbgType | dbgCanon
11 | | dbgToken | dbgParse | dbgDeps
12 | | dbgOpt | noGenFail | genProfile | codeFile(string)
13 | | bkPt(string) | noDbg(string) | dbg(string) | dbgVar(string[])
14 | | frameVars(canonTerm,canonTerm[])
15 | | noAssert(string)
16 | | inPkg(string) | inProg(string) ;
17 |
18 | #op('//+,infix,840); -- Map a list to a string
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Tests/labels.go:
--------------------------------------------------------------------------------
1 | labels{
2 | import go.io.
3 | import go.unit.
4 |
5 | lbT <~ {foo:[]=>string}.
6 |
7 | lbN:[]@=lbT.
8 | lbN..{
9 | foo()=>"lbN".
10 | }.
11 |
12 | lbU:[string]@>lbT.
13 | lbU(S)..{
14 | chuck:string = S.
15 |
16 | foo() => chuck.
17 | }.
18 |
19 | lbTst:[lbT]{}.
20 | lbTst(X) :-
21 | X <= lbN.
22 |
23 | lbUTst:[lbT,string]{}.
24 | lbUTst(X,S) :-
25 | X <= lbU(S).
26 |
27 | labelT:[]$=harness.
28 | labelT<=harness.
29 | labelT..{
30 | doPred() :- lbTst(lbN), \+ lbTst(lbU("U")), lbUTst(lbU("who"),O),
31 | O=="who".
32 | doAction() ->
33 | LL = lbU("who");
34 | ( LL <= Lb *>
35 | stdout.outLine(LL.show()<>" <= "<>Lb.show())
36 | ).
37 | }.
38 |
39 | main(_) ->
40 | checkUnit(labelT).
41 | }
--------------------------------------------------------------------------------
/Tests/csv.go:
--------------------------------------------------------------------------------
1 | /*
2 | * A module to parse a csv file
3 | */
4 | csv{
5 | import go.io.
6 |
7 | csv[]<~{lines:((list[string])-->string)}.
8 | csv:csv[]..{
9 | cell(Cont) --> "\"", Str(Cont,`\"), "\"".
10 | cell([]) --> ",".
11 | cell([C,..ont]) --> [C],{C!=`,}, cell(ont).
12 | cell([]),"\n" --> "\n".
13 |
14 | line([Cell,..more]) --> cell(Cell)!, line(more).
15 | line([]) --> "\n".
16 | line([]) --> eof.
17 |
18 | lines([Line,..more]) --> line(Line)!,lines(more).
19 | lines([]) --> eof.
20 | }.
21 |
22 | grabCSV(File) =>
23 | valof{
24 | f = openInFile(File,unknownEncoding);
25 | Text = f.inText(""); -- This will read the entire file
26 | f.close();
27 | valis csv.lines%%Text.
28 | }.
29 | }
--------------------------------------------------------------------------------
/dl/homeimprovement.dl:
--------------------------------------------------------------------------------
1 | homeimprovement{
2 |
3 | -- A Sample ontology in the DL language
4 |
5 | Action == $instrument=Instrument && $agent=Agent && $target=Feature &&
6 | $location=Location && $reason=Reason && $display=Word.
7 |
8 | Agent == $canPerform=Action && $display=Word .
9 |
10 | Instrument <= thing.
11 |
12 | Feature <= thing.
13 |
14 | Location <= Feature.
15 |
16 | Word <= #en .
17 |
18 | Reason == { iWantTo, aFire, anEarthquake, aFlood, aFreeze }.
19 |
20 | Pipework == Feature && location=home.
21 |
22 | FixPlumbing == Action && $target=Pipework.
23 |
24 | ThawPipes == FixPlumbing && reason=aFreeze.
25 |
26 | CleanDrains == FixPlumbing && target=drains.
27 |
28 | Bedroom <= Location.
29 |
30 | drains{ Pipework && display=wordDrains }.
31 | }
32 |
--------------------------------------------------------------------------------
/Doc/.lyx:
--------------------------------------------------------------------------------
1 | #LyX file created by tex2lyx 0.1.2
2 | \lyxformat 245
3 | \begin_document
4 | \begin_header
5 | \textclass book
6 | \begin_preamble
7 |
8 | \end_preamble
9 | \options fleqn,openright,draft
10 | \language english
11 | \inputencoding latin1
12 | \fontscheme default
13 | \graphics default
14 | \paperfontsize 11
15 | \spacing single
16 | \papersize default
17 | \use_geometry false
18 | \use_amsmath 1
19 | \cite_engine basic
20 | \use_bibtopic false
21 | \paperorientation portrait
22 | \secnumdepth 3
23 | \tocdepth 3
24 | \paragraph_separation indent
25 | \defskip medskip
26 | \quotes_language english
27 | \papercolumns 1
28 | \papersides 2
29 | \paperpagestyle default
30 | \tracking_changes false
31 | \output_changes false
32 | \end_header
33 |
34 | \begin_body
35 |
36 | \end_body
37 | \end_document
38 |
--------------------------------------------------------------------------------
/Engine/Headers/unix.h:
--------------------------------------------------------------------------------
1 | #ifndef _UNIX_COMP_H_
2 | #define _UNIX_COMP_H_
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #if defined(_QNX__) || defined(ibm) /* QNX and ibm need sys/select */
9 | #include
10 | #endif
11 |
12 | #ifdef _WIN32 /* Windows only */
13 | #include
14 | #include
15 | #else
16 | #include
17 | #include
18 | #endif
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | /*
30 | * Sometimes this is not defined ...
31 | */
32 |
33 | int setenv(const char *name,const char *val,int overwrite);
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/tdpl/genparse.go:
--------------------------------------------------------------------------------
1 | genparse{
2 | import types.
3 | import canon.
4 | import cnf.
5 | import go.io.
6 | import go.setlib.
7 |
8 | genTermRecog:[list[rl]] => list[(list[symbol],string)].
9 | genTermRecog([]) => [].
10 | genTermRecog([rl(NT,[ch(C)]),..Rules])=>
11 | valof{
12 | (NTs,oRules) = extractC(Rules,[NT],[],C);
13 | valis [(NTs,[`[,C,`,.`.,`.,`X,`]]),..genTermRecog(oRules)]
14 | }.
15 | genTermRecog([Rl,..ules])=>genTermRecog(ules).
16 |
17 |
18 | private extractC:[char,list[symbol],list[rl],list[rl]]=>(list[symbol],list[rl]).
19 | extractC(_,NTs,Rls,[]) => (NTs,reverse(Rls)).
20 | extractC(C,NTs,Rls,[rl(NT,[ch(C)]),..ules]) => extractC(C,NTs\/[NT],Rls,ules).
21 | extractC(C,NTs,Rls,[rl(NT,Bdy),..ules]) =>
22 | extractC(C,NTs,[rl(NT,Bdy),..Rls],ules).
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/graph/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Build the Go! graphics libraries
3 | #
4 | include ${top_builddir}/go.Make
5 |
6 | SUFFIXES = .af .ah .go .goc
7 |
8 | GO_SRCS = matrix.go transform.go xlib.go widget.go graph.go event.go xlabel.go
9 |
10 | GO_CODE = $(GO_SRCS:.go=.goc)
11 |
12 | EXTRA_DIST = ${GO_SRCS}
13 |
14 | CLEANFILES = ${GO_CODE} $(GO_SRCS:.go=.gof)
15 |
16 | transform.goc: matrix.goc
17 |
18 | xlib.goc: graph.goc
19 |
20 | event.goc: graph.goc xlib.goc
21 |
22 | widget.goc: xlib.goc transform.goc graph.goc event.goc
23 |
24 | xlabel.goc: widget.goc graph.goc event.goc xlib.goc
25 |
26 | all-local: ${GO_CODE}
27 |
28 | install-data-local: ${GO_CODE}
29 | -${top_srcdir}/mkinstalldirs $(DESTDIR)${prefix}/graph
30 | (for XX in ${GO_CODE} ; do\
31 | $(INSTALL_SCRIPT) $${XX} $(DESTDIR)${prefix}/graph; done)
32 |
--------------------------------------------------------------------------------
/Doc/emacs.tex:
--------------------------------------------------------------------------------
1 | \chapter{\go Emacs mode}
2 | \label{emacs}
3 |
4 | Included in the \go system is a simple Emacs mode that makes editing and debugging \go programs simpler. See Section~\vref{install:emacs} for details of how to modify your Emacs environment to access the \go mode.
5 | \begin{aside}
6 | This mode is very much a work in progress, especially the debugging aspect of the mode.
7 | \end{aside}
8 |
9 | \section{Editing \go programs}
10 |
11 |
12 | \section{Debugging \go programs in Emacs}
13 | The \q{C-c C-d} command initiates a \go session under the debugger. It takes two arguments: the name of the package to debug and a list of arguments to pass as command line arguments to the debugged process.
14 |
15 | See Section~\vref{debugger:emacs} for instructions on how to use the default debugger from within Emacs.
16 |
17 |
--------------------------------------------------------------------------------
/Tests/server.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test of the TCP server
3 | */
4 |
5 | server{
6 | import go.io.
7 | import go.stdparse.
8 |
9 | mySrvr:[]@=serverProc.
10 | mySrvr..{
11 | exec(H,I,_,i,o) ->
12 | stdout.outLine("Connection from "<>H<>"/"<>I);
13 | srvr_loop(i,o).
14 |
15 | srvr_loop:[inChannel,outChannel]*.
16 | srvr_loop(i,_):: i.eof() -> stdout.outLine("Connection closed").
17 | srvr_loop(i,o) -> L = i.inText("\n\+4;"); stdout.outLine("recvd :"<>L.show());
18 | o.outLine("You sent "<>listlen(L).show()<>" characters");
19 | (L=[] ? stdout.outLine("control-D received") | srvr_loop(i,o)).
20 | }.
21 |
22 | main([port]) ->
23 | stdout.outLine("Starting server on port "<>port);
24 | tcpServer(naturalOf%%port,mySrvr,utf8Encoding).
25 | }.
26 |
--------------------------------------------------------------------------------
/golex/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Build the Go Lexical generator
3 | #
4 |
5 | include ${top_builddir}/go.Make
6 |
7 | SUFIXES = .go .goc
8 |
9 | GO_SRCS = golex.go golextypes.go genregexp.go gendfa.go gentoken.go
10 |
11 | GO_CODE = $(GO_SRCS:.go=.goc)
12 |
13 | EXTRA_DIST = ${GO_SRCS}
14 |
15 | CLEANFILES = ${GO_CODE} $(GO_SRCS:.go=.gof)
16 |
17 | golex.goc: golextypes.goc genregexp.goc gendfa.goc gentoken.goc
18 |
19 | genregexp.goc: golextypes.goc
20 |
21 | gendfa.goc: golextypes.goc
22 |
23 | gentoken.goc: golextypes.goc
24 |
25 | all-local: golex.goc
26 |
27 | install-data-local: ${GO_CODE}
28 | -${top_srcdir}/mkinstalldirs $(DESTDIR)${prefix}/go/golex
29 | (for XX in ${GO_CODE} ; do\
30 | $(INSTALL_SCRIPT) $${XX} $(DESTDIR)${prefix}/go/golex; done)
31 | $(INSTALL_SCRIPT) -m 0755 golex $(DESTDIR)${prefix}/bin
32 |
--------------------------------------------------------------------------------
/Doc/QuickRef/emacs.tex:
--------------------------------------------------------------------------------
1 | \chapter{\go Emacs mode}
2 | \label{emacs}
3 |
4 | Included in the \go system is a simple Emacs mode that makes editing and debugging \go programs simpler. See Section~\vref{install:emacs} for details of how to modify your Emacs environment to access the \go mode.
5 | \begin{aside}
6 | This mode is very much a work in progress, especially the debugging aspect of the mode.
7 | \end{aside}
8 |
9 | \section{Editing \go programs}
10 |
11 |
12 | \section{Debugging \go programs in Emacs}
13 | The \q{C-c C-d} command initiates a \go session under the debugger. It takes two arguments: the name of the package to debug and a list of arguments to pass as command line arguments to the debugged process.
14 |
15 | See Section~\vref{debugger:emacs} for instructions on how to use the default debugger from within Emacs.
16 |
17 |
--------------------------------------------------------------------------------
/Tests/plip.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test the multiple processes with a simple delay loop
3 | */
4 |
5 | plip{
6 | import go.io.
7 | import go.stdparse.
8 | import go.unit.
9 |
10 | testplip:[integer]@=harness.
11 | testplip(_)<=harness.
12 | testplip(T)..{
13 | doAction() ->
14 | spawn{ plip()};
15 | spawn{ plop()};
16 | stdout.outLine("Running for "<>T.show()<>" secs");
17 | delay(T);
18 | stdout.outLine("time out").
19 | }.
20 |
21 | plip:[]*.
22 | plop:[]*.
23 |
24 | plip() ->
25 | delay(0.5);
26 | stdout.outLine("plip");
27 | plip().
28 |
29 | plop() ->
30 | delay(1.6);
31 | stdout.outLine(" plop");
32 | plop().
33 |
34 | main([T,.._]) ->
35 | checkUnit(testplip(naturalOf%%T)).
36 | main([]) ->
37 | checkUnit(testplip(15)).
38 | }.
39 |
--------------------------------------------------------------------------------
/Tests/suspend.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test the variable suspension stuff
3 | */
4 | suspend{
5 | -- import go.io.
6 |
7 | gen:[symbol]{}.
8 | gen('a') :- __logmsg("trying a"). -- this should trigger the check
9 | gen('b') :- __logmsg("trying b").
10 | gen('c') :- __logmsg("trying c").
11 | gen('d') :- __logmsg("trying d").
12 |
13 |
14 | doMe:[]{}.
15 | doMe() :-
16 | check(X),gen(X),
17 | otherCode(X).
18 |
19 |
20 | check:[symbol++]{}.
21 | check(U) :-
22 | __logmsg("Testing "),
23 | chck1(U),
24 | __logmsg("Ok").
25 |
26 | chck1:[symbol]{}.
27 | chck1('b').
28 | chck1('d').
29 |
30 | otherCode:[symbol]{}.
31 | otherCode(X) :-
32 | __logmsg("Run ..."),
33 | X=='d',
34 | __logmsg("Second check ok").
35 |
36 | main(_) ->
37 | { doMe() }.
38 | }
39 |
--------------------------------------------------------------------------------
/BootCompiler/l.go:
--------------------------------------------------------------------------------
1 | org.go.sys.cell{
2 | cell[T] ::= { get:(()=>T), set:((T)*) }.
3 | cell[_] <~ synchronized[].
4 |
5 | cell(I:T):cell[T]..{
6 | V := I.
7 |
8 | get() => valof{
9 | sync{
10 | valis V
11 | }
12 | }.
13 |
14 | set(N) -> sync{V:=N}.
15 | }.
16 |
17 | dynamic[T] ::= { add:(T)*, delete:(T)* }.
18 |
19 | dynamic(I) <= cell(I).
20 | dynamic(I:list[T]):dynamic[T]..{
21 | add(X) ->
22 | set(get()<>[X]).
23 |
24 | delete(X) ->
25 | set(remove(X,get())).
26 |
27 | LL := len(I).
28 | }.
29 |
30 | len([]) => 0.
31 | len([_,..L]) => len(L)+1.
32 | remove(_,[]) => [].
33 | remove(X,[X,..L]) => remove(X,L).
34 | remove(X,[A,..L]) => [A,..remove(X,L)].
35 |
36 | []<>X=>X.
37 | [E,..X]<>Y=>[E,..X<>Y].
38 |
39 | }
--------------------------------------------------------------------------------
/Tests/wait.go:
--------------------------------------------------------------------------------
1 | wait{
2 | import go.io.
3 | import go.stdparse.
4 | import go.unit.
5 |
6 |
7 | waiter:[integer]@=harness.
8 | waiter(_)<=harness.
9 | waiter(Count)..{
10 | doAction() ->
11 | waiting(spLoop(Count)).
12 |
13 | spLoop:[integer]=>list[thread].
14 | spLoop(0) => [].
15 | spLoop(N) => [spawn {
16 | stdout.outLine(__thread().show()<>" starting");
17 | delay(rand(10));
18 | stdout.outLine(__thread().show()<>" ending")
19 | },..spLoop(N-1)].
20 |
21 | waiting:[list[thread]]*.
22 | waiting([])-> {}.
23 | waiting([H,..L]) -> stdout.outLine("waiting for "<>H.show()); waitfor(H); waiting(L).
24 | }.
25 |
26 | main([K]) ->
27 | checkUnit(waiter(naturalOf%%K)).
28 | main([]) ->
29 | checkUnit(waiter(5)).
30 | }.
--------------------------------------------------------------------------------
/goSSL/libgossl.la:
--------------------------------------------------------------------------------
1 | # libgossl.la - a libtool library file
2 | # Generated by ltmain.sh - GNU libtool 1.4.2 (1.4 2001/11/19 00:06:02)
3 | #
4 | # Please DO NOT delete this file!
5 | # It is necessary for linking the library.
6 |
7 | # The name that we can dlopen(3).
8 | dlname='libgossl.0'
9 |
10 | # Names of this library.
11 | library_names='libgossl.0 libgossl libgossl.0.0.0'
12 |
13 | # The name of the static archive.
14 | old_library='libgossl.a'
15 |
16 | # Libraries that this one depends upon.
17 | dependency_libs=' -lm -ldl'
18 |
19 | # Version information for libgossl.
20 | current=0
21 | age=0
22 | revision=0
23 |
24 | # Is this an already installed library?
25 | installed=no
26 |
27 | # Files to dlopen/dlpreopen
28 | dlopen=''
29 | dlpreopen=''
30 |
31 | # Directory that this library needs to be installed in:
32 | libdir='/opt/go/lib'
33 |
--------------------------------------------------------------------------------
/macros/CVS/Entries:
--------------------------------------------------------------------------------
1 | D/bin////
2 | /.cvsignore/1.1/Sun Sep 21 01:02:34 2003//
3 | /Makefile.am/1.1/Sat Sep 20 04:35:24 2003//
4 | /aap.m4/1.1/Sat Sep 20 04:35:24 2003//
5 | /april.m4/1.1/Sat Sep 20 04:35:24 2003//
6 | /aprildep.m4/1.1/Sat Sep 20 04:35:24 2003//
7 | /aprilext.m4/1.1/Sat Sep 20 04:35:24 2003//
8 | /builddoc.m4/1.1/Sat Sep 20 04:35:24 2003//
9 | /dialox.m4/1.1/Sat Sep 20 04:35:24 2003//
10 | /go.m4/1.1/Sat Sep 20 04:35:24 2003//
11 | /goext.m4/1.1/Sat Sep 20 04:35:24 2003//
12 | /htmldir.m4/1.1/Sat Sep 20 04:35:24 2003//
13 | /icm.m4/1.1/Sat Sep 20 04:35:24 2003//
14 | /java.m4/1.1/Sat Sep 20 04:35:24 2003//
15 | /jtp.m4/1.1/Sat Sep 20 04:35:24 2003//
16 | /mysql.m4/1.1/Sat Sep 20 04:35:24 2003//
17 | /openssl.m4/1.1/Sat Sep 20 04:35:24 2003//
18 | /webstream.m4/1.1/Sat Sep 20 04:35:24 2003//
19 | /debug.m4/1.1/Sun Sep 21 04:09:04 2003//
20 |
--------------------------------------------------------------------------------
/goSSL/.libs/libgossl.lai:
--------------------------------------------------------------------------------
1 | # libgossl.la - a libtool library file
2 | # Generated by ltmain.sh - GNU libtool 1.4.2 (1.4 2001/11/19 00:06:02)
3 | #
4 | # Please DO NOT delete this file!
5 | # It is necessary for linking the library.
6 |
7 | # The name that we can dlopen(3).
8 | dlname='libgossl.0'
9 |
10 | # Names of this library.
11 | library_names='libgossl.0 libgossl libgossl.0.0.0'
12 |
13 | # The name of the static archive.
14 | old_library='libgossl.a'
15 |
16 | # Libraries that this one depends upon.
17 | dependency_libs=' -lm -ldl'
18 |
19 | # Version information for libgossl.
20 | current=0
21 | age=0
22 | revision=0
23 |
24 | # Is this an already installed library?
25 | installed=yes
26 |
27 | # Files to dlopen/dlpreopen
28 | dlopen=''
29 | dlpreopen=''
30 |
31 | # Directory that this library needs to be installed in:
32 | libdir='/opt/go/lib'
33 |
--------------------------------------------------------------------------------
/dl/types.dl:
--------------------------------------------------------------------------------
1 | types{
2 | -- A demonstration of using DL for capturing types
3 |
4 | -- We assume some base types built-in: Integer, Float, Char, Symbol, Thing.
5 |
6 | -- A list type has a head and a tail....
7 |
8 | List == $head:Thing && $tail:List | { nil } .
9 |
10 | -- $tail introduces the tail role, and $tail=List declares that the domain
11 | -- of tail is List.
12 |
13 | -- The convention is that classes are capitalized and individuals are not
14 |
15 | -- A list of integers is a list with an additional restriction
16 |
17 | IntList == List && $head:Integer.
18 |
19 | -- We can define a list of 1's by making an existential commitment:
20 |
21 | OneList == List && $head=1.
22 |
23 | -- An enumeration is defined by giving the explicit individuals in the class
24 |
25 | WeekDays = { sunday, monday, ..., saturday }.
26 |
27 |
28 |
--------------------------------------------------------------------------------
/gpg/gpgparser.GPrules:
--------------------------------------------------------------------------------
1 | /*
2 | * The parser for gpg, written in gpg itself.
3 | */
4 |
5 | %%
6 |
7 | gpg: preamble MARK rules MARK { $$=GPGRULESET($1,$3)} ;
8 |
9 | preamble: definition { $$=$1}
10 | | preamble definition { $$ = SEQ($1,$2) }
11 | ;
12 |
13 | definition : operatordef
14 | | startdef
15 | | includedef
16 | | importdef
17 | | expectdef
18 | ;
19 |
20 | operatordef : TOKEN tokenspecs { $$=TOKENSPEC($2) }
21 | | LEFT tokenspecs { $$ = OPERATORSPEC($2,leftA) }
22 | | RIGHT tokenspecs { $$ = OPERATORSPEC($2,rightA) }
23 | | NONASSOC tokenspecs { $$ = OPERATORSPEC($2,nonA) }
24 | ;
25 |
26 | tokenspecs: tokenspec
27 | | tokenspecs tokenspec { $$=SEQ($1,$2) }
28 | ;
29 |
30 | tokenspec: ID { $$ = N($1) } ;
31 |
32 | includedef : CENTBRACE { $$=$1 };
33 |
--------------------------------------------------------------------------------
/Engine/Headers/setops.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Interface to April set handling functions
3 | */
4 | #ifndef _SETOPS_H_
5 | #define _SETOPS_H_
6 | logical equalcell(register objPo c1,register objPo c2);
7 |
8 | /* Escape interface */
9 | retCode m_head(processpo p,objPo *args);
10 | retCode m_front(processpo p,objPo *args);
11 | retCode m_back(processpo p,objPo *args);
12 | retCode m_tail(processpo p,objPo *args);
13 | retCode m_listlen(processpo p,objPo *args);
14 | retCode m_nth(processpo p,objPo *args);
15 | retCode m_union(processpo p,objPo *args);
16 | retCode m_sect(processpo p,objPo *args);
17 | retCode m_diff(processpo p,objPo *args);
18 | retCode m_app(processpo p,objPo *args);
19 | retCode m_iota(processpo p,objPo *args);
20 | retCode m_subset(processpo p,objPo *args);
21 | retCode m_disjoint(processpo p,objPo *args);
22 | retCode m_sort(processpo p,objPo *args);
23 | #endif
24 |
--------------------------------------------------------------------------------
/macros/debug.m4:
--------------------------------------------------------------------------------
1 | dnl NA_DEBUG(default)
2 | dnl
3 | dnl Description:
4 | dnl Enable debugging
5 | dnl
6 | dnl Defines
7 | dnl ALLTRACE
8 | dnl
9 |
10 | AC_DEFUN(NA_DEBUG,[
11 |
12 | na_debug=$1
13 |
14 | dnl Set up debugging flag
15 | AC_ARG_ENABLE(debug,
16 | [ --enable-debug Turn on debugging code],
17 | [case "${enableval}" in
18 | yes)
19 | CFLAGS='-g -Wall'
20 | AC_DEFINE(ALLTRACE)
21 | ;;
22 | semi)
23 | CFLAGS='-g -Wall -O2'
24 | AC_DEFINE(ALLTRACE)
25 | ;;
26 | profile)
27 | CFLAGS='-g -pg -Wall'
28 | AC_DEFINE(ALLTRACE)
29 | ;;
30 |
31 | no) CFLAGS='-O3 -Wall -DNDEBUG'
32 | AC_DEFINE(NDEBUG)
33 | AC_DEFINE(NOCOLOURS)
34 | ;;
35 | *) CFLAGS='${enableval}'
36 | AC_DEFINE(ALLTRACE)
37 | ;;
38 | esac],[CFLAGS='-O3 -Wall'
39 | AC_DEFINE(NDEBUG)
40 | AC_DEFINE(NOCOLOURS)])
41 |
42 | ])
--------------------------------------------------------------------------------
/gpg/grab.go:
--------------------------------------------------------------------------------
1 | gpg.grab{
2 | import go.io.
3 |
4 | grabData:[string]=>(string,string,string).
5 | grabData(fn)=>splitUp(split(suckIn(fn),[])).
6 |
7 | private suckIn:[string]=>string.
8 | suckIn(Fl) =>
9 | valof{
10 | f = openInFile(Fl,unknownEncoding);
11 | valis f.inText(""); -- This will read the entire file
12 | f.close();
13 | }.
14 |
15 | private split:[string,string]=>(string,string).
16 | split([],L) => (reverse(L),[]).
17 | split([`%,`%,`\n,..R],L) => (reverse(L),R).
18 | split([C,..R],L) => split(R,[C,..L]).
19 |
20 | private splitUp:[(string,string)]=>(string,string,string).
21 | splitUp((Pre,[])) =>
22 | valof{
23 | (T,Post) = split(Pre,[]);
24 | valis ([],T,Post)
25 | }.
26 | splitUp((Pre,P)) =>
27 | valof{
28 | (T,Post) = split(P,[]);
29 | valis (Pre,T,Post)
30 | }.
31 | }.
32 |
33 |
--------------------------------------------------------------------------------
/graph/xlabel.go:
--------------------------------------------------------------------------------
1 | /*
2 | * A library to implement a the label widget
3 | */
4 | graph.xlabel{
5 | import graph.widget.
6 | import graph.graph.
7 | import graph.event.
8 | import graph.xlib.
9 | import go.io.
10 |
11 |
12 | private gLbl:[string,font,dimension,dimension,dimension,dimension,container]@>widget.
13 | gLbl(_,_,mnSze,Sze,prSze,mxSze,Par)<=widget(mnSze,Sze,prSze,mxSze,Par).
14 | gLbl(Lbl,Fnt,mnSze,Sze,prSze,mxSze,Par)..{
15 | gc:integer = xCreateGC([gxFontName(Fnt.fontName())]).
16 |
17 | paint(wId,rectangle(X,Y,_,_)) ->
18 | dim(_,H).=size();
19 | stdout.outLine("Painting label: "<>Lbl<>" at "<>(X,Y+H).show());
20 | xDrawString(wId,gc,X,Y+H,Lbl).
21 | }.
22 |
23 | gLabel:[string,font,container]=>widget.
24 | gLabel(Lbl,Fnt,Par) =>
25 | valof{
26 | Sze = Fnt.stringSize(Lbl);
27 | valis gLbl(Lbl,Fnt,Sze,Sze,Sze,Sze,Par)
28 | }.
29 |
30 | }
--------------------------------------------------------------------------------
/Tests/sieve.go:
--------------------------------------------------------------------------------
1 | sieve{
2 | import go.io.
3 | import go.unit.
4 | import go.stdparse.
5 |
6 | sieve:[list[logical],integer]=>list[integer].
7 | sieve([],_)=>[].
8 | sieve([true,..L],I) => [I,..sieve(filter(L,1,I),I+1)].
9 | sieve([false,..L],I) => sieve(L,I+1).
10 |
11 | filter:[list[logical],integer,integer]=>list[logical].
12 | filter([],_,_)=>[].
13 | filter([_,..L],P,P)=>[false,..filter(L,1,P)].
14 | filter([B,..L],Ix,P) => [B,..filter(L,Ix+1,P)].
15 |
16 | trues:[integer]=>list[logical].
17 | trues(0)=>[].
18 | trues(Ix)=>[true,..trues(Ix-1)].
19 |
20 | testSieve:[integer]@=harness.
21 | testSieve(_)<=harness.
22 | testSieve(N)..{
23 | doAction() ->
24 | stdout.outLine("Primes up to "<>N.show()<>"\t "<>listlen(sieve(trues(N),2)).show())
25 | }.
26 |
27 | main([]) -> checkUnit(testSieve(128)).
28 | main([N]) -> checkUnit(testSieve(naturalOf%%N)).
29 | }
--------------------------------------------------------------------------------
/Tests/qsort.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Quicksort
3 | */
4 |
5 | qsort{
6 | import go.io.
7 | import go.unit.
8 | import go.sort.
9 |
10 | i:[]@=comparable[integer].
11 | i..{
12 | less(X,Y) :- X
37 | checkUnit(sorttest).
38 | }.
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/BootCompiler/go_tok.ah:
--------------------------------------------------------------------------------
1 |
2 | yyTokType ::=
3 | ID(string)
4 | | IN(number)
5 | | FT(number)
6 | | STR(string)
7 | | QUOTE(string)
8 | | CH(char)
9 | | LPAR -- round paren
10 | | RPAR
11 | | LBRA -- square bracket
12 | | RBRA
13 | | LBRCE -- breace
14 | | RBRCE
15 | | QBRA -- quine quote
16 | | QKET
17 | | COMMA
18 | | CONS
19 | | TERM
20 | | EOF;
21 |
22 | yyToken ::= (yyTokType?yyTok,number?yyLine,number?yyPos,number?yyLPos);
23 |
24 | fileLoc ::= noLoc | loc(string,number,number,number);
25 |
26 | yyType ::=
27 | IDEN(fileLoc,string)
28 | | INT(fileLoc,number)
29 | | FLT(fileLoc,number)
30 | | ST(fileLoc,string)
31 | | SYM(fileLoc,string)
32 | | CHR(fileLoc,char)
33 | | APPLY(fileLoc,yyType,yyType[])
34 | | BRACE(fileLoc,yyType,yyType[])
35 | | SQUARE(fileLoc,yyType,yyType[]) -- handle the name[t1,..,tk] form
36 | | TPL(fileLoc,yyType[])
37 | | VOID
38 | | END
39 | ;
40 |
41 |
--------------------------------------------------------------------------------
/Tests/timeouts.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test timeouts
3 | */
4 |
5 | timeouts{
6 | import go.io.
7 | import go.unit.
8 | import go.stdparse.
9 | import go.mbox.
10 |
11 | plip:[dropbox[symbol],mailbox[symbol]]*.
12 | plip(T,Bx) ->
13 | delay(rand(1.0));
14 | T.post('plip');
15 | plip(T,Bx).
16 |
17 | plop:[mailbox[symbol]]*.
18 | plop(Bx) ->
19 | case Bx.nextW(0.5) in (
20 | 'plip' -> stdout.outLine("plip")
21 | )
22 | onerror(
23 | timedout -> stdout.outLine(" plop"));
24 | plop(Bx).
25 |
26 | timeouts:[float]@=harness.
27 | timeouts(_)<=harness.
28 | timeouts(T)..{
29 | doAction()->
30 | H = mailbox();
31 | spawn{ plop(H)};
32 | spawn{ plip(H.dropbox(),mailbox()) };
33 | delay(T).
34 | }.
35 |
36 | main([]) ->
37 | checkUnit(timeouts(10.0)).
38 | main([N]) ->
39 | checkUnit(timeouts(floatOf%%N)).
40 | }.
41 |
--------------------------------------------------------------------------------
/Tests/trans.go:
--------------------------------------------------------------------------------
1 | trans{
2 | import go.io.
3 | import go.unit.
4 |
5 | pred[T]<~{ tst:[T,T]{}}.
6 |
7 | trans:[pred[T]]@=pred[T].
8 | trans(B)..{
9 | tst(X,Y) :- B.tst(X,Y).
10 | tst(X,Y) :- B.tst(X,Z), tst(Z,Y).
11 | }.
12 |
13 | parent:[]@=pred[symbol].
14 | parent..{
15 | tst('sally', 'bob').
16 | tst('mike', 'bob').
17 | tst('bob','foo').
18 | }.
19 |
20 | ancestor:pred[symbol] = trans(parent).
21 |
22 | transtest:[]@=harness.
23 | transtest<=harness.
24 | transtest..{
25 | doPred() :-
26 | parent.tst('sally','bob'),
27 | \+parent.tst('foo',_),
28 | ancestor.tst('sally','foo'),
29 | ancestor.tst('mike','bob'),
30 | \+ ancestor.tst('bob','mike').
31 | doAction() ->
32 | stdout.outLine("Descendants of sally: "<>{X || ancestor.tst('sally',X)}.show()<>"\n")
33 | }.
34 |
35 | main(_) ->
36 | checkUnit(transtest).
37 | }
38 |
--------------------------------------------------------------------------------
/rdf/n3parser.go:
--------------------------------------------------------------------------------
1 | rdf.n3parser{
2 |
3 | import go.io.
4 | import go.stdparse.
5 | import n3lex.
6 |
7 | -- Some standard names
8 |
9 | private RDFS_A:[rdfStore]=>string.
10 | RDFS_A(Store) => Store.lookupNameSpace('rdfs')<>"type".
11 |
12 | n3parser:[string]=>list[rdfStatement].
13 | n3parser(File) :: parse%%tokenizeFile(File).
14 |
15 | private parse:[list[rdfStatement]]-->list[yyToken].
16 | parse([]) --> eof.
17 |
18 | private simpleStatement:[rdfStore]-->list[yyToken].
19 | simpleStatement(Store) --> subject(Subject), propertyList(Store,Subject).
20 |
21 | private subject:[rdfResource]-->list[yyToken].
22 | subject(Sub) --> expression(Sub).
23 |
24 | private verb:[rdfResource]-->list[yyToken].
25 | verb(Pred) --> expression(Pred).
26 | verb(RDF_A) --> [Tk], { Tk.token()=A }.
27 |
28 | private object:[rdfResource]-->list[yyToken].
29 | subject(Obj) --> expression(Obj).
30 |
31 |
32 |
33 | }
--------------------------------------------------------------------------------
/go.spec.in:
--------------------------------------------------------------------------------
1 | # Note that this is a partially relocatable package (IYKWYAD)
2 | %define prefix @prefix@
3 |
4 | Summary: The Go! programming language system
5 | Name: go
6 | Version: @VERSION@
7 | Release: 1
8 | Copyright: GPL
9 | Group: Development/Languages
10 | Source: http://www.nar.fujitsulabs.com/downloads/
11 | Obsoletes: april
12 | Requires: icm
13 |
14 | Vendor: Francis G. McCabe
15 | Packager: Francis G. McCabe
16 | URL: http://www.nar.fujitsulabs.com/go/
17 | Docdir: @prefix@/doc
18 |
19 | %description
20 | Go! is a logic programming language that has been
21 | designed to be effective for developing multi-agent systems that are
22 | distributed, especally Internet based.
23 |
24 | %changelog
25 | * Tue Feb 29 2000 F.G.McCabe
26 |
27 | %packages
28 |
29 | %files
30 | %defattr(-, root, root)
31 |
32 | @prefix@
33 |
34 | # %doc AUTHORS COPYING ChangeLog NEWS README
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Tests/init.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test initialization of different kinds
3 | */
4 | init{
5 | import go.io.
6 | import go.unit.
7 |
8 | itype<~{ foo:[]* }.
9 |
10 | iclass:[]@>itype.
11 | iclass()..{
12 | X:float := valof{
13 | Z = 2.0*45.0;
14 | stdout.outLine("initializating X to "<>Z.show()<>" in "<>this.show());
15 | valis Z
16 | }.
17 |
18 | ${
19 | X := X*23.0;
20 | }.
21 |
22 | show()=>"iClass".
23 |
24 | foo:[]*.
25 | foo() ->
26 | stdout.outLine("X = "<>X.show()).
27 |
28 | ${
29 | stdout.outLine("X inited to "<>X.show()<>" in "<>this.show());
30 | }.
31 | }.
32 |
33 | testinit:[]@=harness.
34 | testinit<=harness.
35 | testinit..{
36 | doAction() ->
37 | O = iclass();
38 | stdout.outLine("$iclass = "<>(O).show());
39 | O.foo()
40 | }.
41 |
42 | main(_) ->
43 | checkUnit(testinit).
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/Tests/test.json:
--------------------------------------------------------------------------------
1 | {
2 | "Image": {
3 | "Width": 800,
4 | "Height": 600,
5 | "Title": "View from 15th Floor",
6 | "Thumbnail": {
7 | "Url": "http://www.example.com/image/481989943",
8 | "Height": 125,
9 | "Width": "100"
10 | },
11 | "IDs": [116, 943, 234, 38793]
12 | },
13 | "Locations" : [
14 | {
15 | "precision": "zip",
16 | "Latitude": 37.7668,
17 | "Longitude": -122.3959,
18 | "Address": "",
19 | "City": "SAN FRANCISCO",
20 | "State": "CA",
21 | "Zip": "94107",
22 | "Country": "US"
23 | },
24 | {
25 | "precision": "zip",
26 | "Latitude": 37.371991,
27 | "Longitude": -122.026020,
28 | "Address": "",
29 | "City": "SUNNYVALE",
30 | "State": "CA",
31 | "Zip": "94085",
32 | "Country": "US"
33 | }
34 | ]
35 | }
36 |
--------------------------------------------------------------------------------
/Doc/QuickRef/quick.lop:
--------------------------------------------------------------------------------
1 | \contentsline {program}{\numberline {7.2.1}{\ignorespaces A simple {\texorpdfstring {\unhbox \voidb@x \hbox {\tt queue}}{queue}} class}}{79}{program.7.2.1}
2 | \contentsline {program}{\numberline {7.3.1}{\ignorespaces An {\texorpdfstring {\unhbox \voidb@x \hbox {\tt animal}}{animal}} class}}{83}{program.7.3.1}
3 | \contentsline {program}{\numberline {7.3.2}{\ignorespaces An {\texorpdfstring {\unhbox \voidb@x \hbox {\tt ostrich}}{ostrich}} class}}{84}{program.7.3.2}
4 | \contentsline {program}{\numberline {7.5.1}{\ignorespaces An inner parasite}}{90}{program.7.5.1}
5 | \contentsline {program}{\numberline {7.5.2}{\ignorespaces An exported inner parasite}}{91}{program.7.5.2}
6 | \contentsline {program}{\numberline {7.5.3}{\ignorespaces A {\texorpdfstring {\unhbox \voidb@x \hbox {\tt sort}}{sort}} function}}{94}{program.7.5.3}
7 | \contentsline {program}{\numberline {13.3.1}{\ignorespaces A theory about being on top of yourself}}{174}{program.13.3.1}
8 |
--------------------------------------------------------------------------------
/dl/dl.dl:
--------------------------------------------------------------------------------
1 | dl{
2 | -- An ontology language with similar expressive power to OWL-DL
3 |
4 | -- It supports individuals, classes, property restrictions.
5 |
6 | -- Class operators include definition, conjunction, disjunction
7 |
8 | -- Roles may have universals, existentials (no cardinality)
9 |
10 | -- A concept definition:
11 |
12 | class Pizza {
13 | -- Definitions go in here
14 |
15 | -- A universal restriction:
16 | topping: $PizzaTopping.
17 |
18 | -- An existential restriction:
19 | base: #PizzaBase.
20 |
21 | -- End of Pizza class
22 | }.
23 |
24 | -- A vegetarian pizza:
25 | class Vegetarian is Pizza {
26 | -- With addition restrictions
27 | topping: \Meat.
28 | }.
29 |
30 | -- Toppings come in a limited range
31 | class Topping one-of { pepporoni, olive, cheese }.
32 |
33 | -- An individual
34 | pepporoni a Meat.
35 |
36 | olive a Vegetable.
37 |
38 | cheese a DairyProduct.
39 |
40 | --
41 |
42 | }
--------------------------------------------------------------------------------
/golex/types.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Special type package for golex
3 | (c) 2006 F.G. McCabe
4 |
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation; either version 2 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 |
19 | Contact: Francis McCabe
20 | */
21 | go.golex.types{
22 | yyStream <~ { next:[]=>char. }.
23 | }
--------------------------------------------------------------------------------
/Tests/persontest.go:
--------------------------------------------------------------------------------
1 | persontest{
2 | import go.io.
3 | import person.
4 | import go.unit.
5 |
6 | someone:[string]@=person.
7 | someone(Name)..{
8 | name()=>Name.
9 | spouse()=>noone.
10 | lives(nowhere).
11 | }.
12 |
13 | personTest:[]@=harness.
14 | personTest<=harness.
15 | personTest..{
16 | doAction() ->
17 | P = person#person("Pee",noone);
18 | go.io#stdout.outLine("I am "<>P.show());
19 | stdout.outLine("spouse is "<>P.spouse().show());
20 | S = student("Joe",person#imperial,P);
21 | stdout.outLine("S is "<>S.show());
22 | stdout.outLine("S's spouse is "<>S.spouse().show());
23 | ( S<=Cl *> stdout.outLine(S.show()<>" is an instance of "<>Cl.show())).
24 | doPred() :-
25 | coHabit(person("P",noone),noone),
26 | student("Joe",imperial,noone) <= person(_,_).
27 | }.
28 |
29 | main(_) ->
30 | checkUnit(personTest).
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/Agent/contract.gh:
--------------------------------------------------------------------------------
1 | /*
2 | Header files for contract module
3 | (c) 1994-2001 Imperial College and F.G. McCabe
4 |
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation; either version 2 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 |
19 | Contact: Francis McCabe
20 | */
21 |
22 | condition(OT) ::= pred(Goal(OT)) |
--------------------------------------------------------------------------------
/Tests/ancestor.go:
--------------------------------------------------------------------------------
1 | ancestor{
2 | import go.io.
3 | import go.unit.
4 |
5 | parent:[symbol,symbol]{}.
6 | parent('a','b').
7 | parent('a','c').
8 | parent('c','d').
9 | parent('c','e').
10 | parent('e','f').
11 |
12 | ancestor:[symbol,symbol]{}.
13 | ancestor(X,Y) :- parent(X,Y).
14 | ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y).
15 |
16 | ancestorTester:[]@=harness.
17 |
18 | ancestorTester <= harness.
19 | ancestorTester..{
20 | doAction() -> ancestor('a',X) *> stdout.outLine("A is ancestor of " <> X^).
21 |
22 | errorAction()->
23 | (_:harness).doAction(). -- this is supposed to fail
24 |
25 | doPred() :- parent('a','b'), -- define the tests to be applied here
26 | \+parent('b','a'),
27 | ancestor('a','f'),
28 | \+ancestor('f',_).
29 |
30 | show()=> "ancestor test".
31 | }.
32 |
33 | main(_) -> checkUnit(ancestorTester).
34 | }
35 |
--------------------------------------------------------------------------------
/Engine/Headers/debug.h:
--------------------------------------------------------------------------------
1 | #ifndef _GO_DEBUG_H_
2 | #define _GO_DEBUG_H_
3 |
4 | /* Declarations of the debugger hooks */
5 |
6 | extern logical SymbolDebug;
7 |
8 | #ifdef EXECTRACE
9 | extern logical debugging; /* Level of debugging */
10 | #endif
11 |
12 | typedef enum {
13 | nextIns, nextSucc, nextFail, nextBreak
14 | } DebugWaitFor;
15 |
16 | extern long cmdCounter;
17 | extern DebugWaitFor waitingFor; /* waiting for next instruction */
18 | extern logical tracing; /* do we show each instruction */
19 |
20 | extern uniChar debuggerPrefix[MAX_SYMB_LEN];
21 |
22 | void showReg(ptrPo a,char *name,integer reg);
23 |
24 | retCode debug_stop(processPo p,ptrI prog,insPo pc,ptrI cprog,insPo cpc,ptrPo a,ptrPo y,
25 | ptrPo S,long Svalid,rwmode mode,
26 | choicePo B,choicePo SB,choicePo T,
27 | ptrPo hBase,ptrPo H,
28 | trailPo trail,
29 | ptrI prefix);
30 |
31 | void showInstructions(codePo code,insPo pc,int count);
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/Tests/syncwait.go:
--------------------------------------------------------------------------------
1 | /* Test the conditional sync with three threads -- two will fire but block and the third
2 | will enable the other two to run
3 | */
4 | syncwait{
5 | import go.io.
6 | import go.stdparse.
7 | import go.unit.
8 | import go.cell.
9 |
10 | test:[cell[t],t]{}.
11 | test(C,X) :-
12 | action{ stdout.outLine(C^<>" has value "<>C.get()^) }, C.get()==X.
13 |
14 | waiter:[cell[symbol]]*.
15 | waiter(C) ->
16 | sync(C){
17 | test(C,'yes') ->
18 | stdout.outLine("I can go")
19 | }.
20 |
21 | doer:[cell[t]]*.
22 | doer(C) ->
23 | delay(1);
24 | -- stdout.outLine("setting to yes");
25 | C.set('yes').
26 |
27 | check:[]@=harness.
28 | check<=harness.
29 | check..{
30 | doAction() ->
31 | C = cell('no');
32 | spawn{ doer(C) };
33 | T0 = spawn{ waiter(C) };
34 | waiter(C);
35 | waitfor(T0).
36 | }.
37 |
38 | main(_) ->
39 | checkUnit(check).
40 | }
41 |
--------------------------------------------------------------------------------
/rdf/rdfparser.gpg:
--------------------------------------------------------------------------------
1 | /*
2 | * A parser for N3.
3 | */
4 |
5 | %{
6 |
7 | import n3lex.
8 |
9 | yyType ::= N(integer) | F(float) | D(float) |
10 | L(string) | V(string) |
11 | PATH(list[yyType]) | props(list[(yyType,yyType)]) |
12 | FORMS(list[yyType]) |
13 | TRIPLE(yyType,yyType,yyType) | EXISTENTIAL(yyType) | UNIVERSAL(yyType) |
14 | SEQ(yyType,yyType) | PFX(yyType,yyType).
15 |
16 | %}
17 |
18 | %token INT%{integer%} FLT%{float%} DEC%{float%} BARENAME%{string%}
19 | %token URI%{string%} QNAME%{string,string%}
20 | %token PREFIX A IS HAS OF LANG%{string%} ID%{string%} HAT EQUAL LESSEQ GREATERQ
21 | %token EOF DOT COMMA SEMI LPAR RPAR LSQ RSQ LBRC RBRC
22 |
23 | %start n3
24 |
25 | %%
26 |
27 | n3: statements ;
28 |
29 | statements : statements DOT statement { SEQ($1,$3) }
30 | | statement DOT
31 | |
32 | ;
33 |
34 | statement : declaration | existential | simpleStatement | universal ;
35 |
36 | declaration : PREFIX prefix explicituri { PFX($2,$3) };
37 |
38 |
39 |
--------------------------------------------------------------------------------
/golex/token.alx:
--------------------------------------------------------------------------------
1 | -- Tokenizer for a simple programming language
2 |
3 | #include "token.ah";
4 |
5 | %%
6 |
7 | -- keyword rules
8 |
9 | "if" => { IF }
10 | "then" => { THEN }
11 | "else" => { ELSE }
12 | "while" => { WHILE }
13 | "do" => { DO }
14 |
15 | -- identifier rule
16 |
17 | [a-zA-Z_][a-zA-Z_0-9]* => { ID(string%%yyTok) }
18 |
19 | -- number rules
20 |
21 | "-"?[0-9]+ => { INT(tok2Num(yyTok)) }
22 |
23 | "-"?[0-9]+"."[0-9]+([eE][-+]?[0-9]+)? => { REAL(tok2Num(yyTok)) }
24 |
25 | -- punctuation rules
26 |
27 | "(" => { LPAREN }
28 | ")" => { RPAREN }
29 | "," => { COMMA }
30 | ";" => { SEMI }
31 |
32 | -- White space and comments
33 | [ \n\t\b\r]+ => skip -- ignore white space
34 |
35 | "--"[^\n]*"\n" -- line comment
36 |
37 | "/*" => -- continuous comment
38 |
39 | "*/" =>
40 | . -- implies a skip
41 |
42 | %%
43 |
44 | -- The postamble
45 |
46 | tok2Num(token) => number%%(string%%token);
47 |
48 |
49 |
--------------------------------------------------------------------------------
/golex/test.glx:
--------------------------------------------------------------------------------
1 | -- A Test golex file
2 |
3 | -- The preamble ...
4 |
5 | import go.stdparse.
6 |
7 | yyTokType ::= INT(integer) | FLT(float) | ID(string) | EOF.
8 |
9 | %%
10 |
11 | -- The rules ...
12 |
13 | [ \n\t\b\r]+ => skip -- ignore white space
14 |
15 | "--"[^\n]*"\n" -- line comment
16 |
17 | "-"?[0-9]+ => (INT(integerOf%%yyTok))
18 |
19 | "-"?[0-9]+("."[0-9]+([eE][-+]?[0-9]+)?) => (FLT(floatOf%%yyTok))
20 |
21 | [a-zA-Z_][a-zA-Z_0-9]* => (ID(yyTok))
22 |
23 | -- We try out the states here
24 | "/*" => -- long comment
25 |
26 | "*/" =>
27 | . -- implies a skip
28 |
29 | %%
30 |
31 | -- The postamble
32 |
33 | main([])::stdin.eof() -> {}.
34 | main([]) ->
35 | yyTokenizeAll(stdin.inLine("\n"));
36 | main([]).
37 |
38 | main(L) ->
39 | (S in L *>
40 | f = openInFile(S,unknownEncoding);
41 | Text = f.inText("");
42 | f.close();
43 | parseAll(yytest(Text,0,0))).
44 |
--------------------------------------------------------------------------------
/gpg/gpgTypes.go:
--------------------------------------------------------------------------------
1 | gpg.gpgTypes{
2 |
3 | item <~ thing.
4 |
5 | item:[integer,symbol,list[symbol],list[symbol],list[symbol]]@=item.
6 | item(Rule,Nt,Pre,Pos,LA)..{
7 | show()=>"Rule : "<>Rule.show()<>" "<>Nt.show()<>" -> "<>Pre.show()<>
8 | " . "<>Pos.show().
9 | }.
10 |
11 |
12 | actionT ::= shiftOn(symbol,integer,integer)
13 | | reduceBy(symbol,integer)
14 | | accept(symbol)
15 | | recoverError(list[symbol],integer,integer)
16 | | disabled(actionT).
17 |
18 | tokenPriority ::= lA(integer) | rA(integer) | nA(integer) | tA.
19 |
20 | rule <~ thing.
21 |
22 | rule:[integer,symbol,list[symbol],list[symbol],string,tokenPriority]@=rule.
23 | rule(R,NT,Pre,Suff,Act,OpAss)..{
24 | show() => R.show()<>": "<>NT.show()<>" -> "<>
25 | showLits(Pre)<>" . "<>showLits(Suff)<>OpAss.show()<>"{"<>Act<>"}".
26 |
27 | showLits:[list[symbol]]=>string.
28 | showLits([])=>"".
29 | showLits([A,..B])=>explode(A)<>" "<>showLits(B).
30 | }.
31 |
32 |
33 | }.
--------------------------------------------------------------------------------
/tdpl/types.go:
--------------------------------------------------------------------------------
1 | types{
2 | import go.showable.
3 |
4 | item <~ thing.
5 |
6 | item:[integer,symbol,list[symbol],list[symbol],list[symbol]]@=item.
7 | item(Rule,Nt,Pre,Pos,LA)..{
8 | show()=>"Rule : "<>Rule.show()<>" "<>Nt.show()<>" -> "<>Pre.show()<>
9 | " . "<>Pos.show().
10 | }.
11 |
12 |
13 | actionT ::= shiftOn(symbol,integer,integer)
14 | | reduceBy(symbol,integer)
15 | | accept(symbol)
16 | | recoverError(list[symbol],integer,integer)
17 | | disabled(actionT).
18 |
19 | tokenPriority ::= lA(integer) | rA(integer) | nA(integer) | tA.
20 |
21 | rule <~ thing.
22 |
23 | rule:[integer,symbol,list[symbol],list[symbol],string,tokenPriority]@=rule.
24 | rule(R,NT,Pre,Suff,Act,OpAss)..{
25 | show() => R.show()<>": "<>NT.show()<>" -> "<>
26 | showLits(Pre)<>" . "<>showLits(Suff)<>OpAss.show()<>"{"<>Act<>"}".
27 |
28 | showLits:[list[symbol]]=>string.
29 | showLits([])=>"".
30 | showLits([A,..B])=>explode(A)<>" "<>showLits(B).
31 | }.
32 | }
--------------------------------------------------------------------------------
/Tests/suspsort.go:
--------------------------------------------------------------------------------
1 | suspsort{
2 | import go.io.
3 | import go.unit.
4 |
5 | delete:[integer,list[integer],list[integer]]{}.
6 | delete(X,[X,..L],L).
7 | delete(X,[Y,..L],[Y,..DL]) :- delete(X,L,DL).
8 |
9 | permute:[list[integer],list[integer]]{}.
10 | permute([U],[U]).
11 | permute(L,[X,..PDL]) :-
12 | delete(X,L,DL),
13 | permute(DL,PDL).
14 |
15 | sort:[list[integer],list[integer]]{}.
16 | sort([U],[U]):--true.
17 | sort(L,SL) :-- ordered(SL),permute(L,SL).
18 |
19 | ordered:[list[integer]++]{}.
20 | ordered([U,..L]):-
21 | lessOrdered(U,L).
22 |
23 | lessOrdered:[integer++,list[integer]++]{}.
24 | lessOrdered(_,[]).
25 | lessOrdered(U,[V,..L]) :- V@@U
31 | {sort([-3,4,2,-4,1],S)};stdout.outLine(S.show()).
32 |
33 | doPred() :-
34 | sort([-3,4,2,1],S),
35 | S = [-3,1,2,4].
36 | }.
37 |
38 | main(_) ->
39 | checkUnit(susptest).
40 | }
41 |
--------------------------------------------------------------------------------
/Tests/susmoney.go:
--------------------------------------------------------------------------------
1 | /*
2 | * S E N D + M O R E = M O N E Y
3 | * Version using variable suspensions
4 | */
5 |
6 | susmoney{
7 | import go.unit.
8 | import go.io.
9 |
10 | pick:[list[t],t,list[t]]{}.
11 | pick([X,..Y],X,Y).
12 | pick([X,..Y],A,[X,..Z]) :- pick(Y,A,Z).
13 |
14 | solve:[list[integer],list[integer],list[integer]]{}.
15 | solve([S,E,N,D],[M,O,R,E],[M,O,N,E,Y]) :-
16 | M=1, C4=1, R9 = [0,2,3,4,5,6,7,8,9],
17 | pick(R9,S@@S>0,R8),
18 | C3 in [0,1],
19 | C2 in [0,1],
20 | C1 in [0,1],
21 | pick(R8,O@@O = S+M+C3-10*C4,R7),
22 | pick(R7,E,R6),
23 | pick(R6,N@@N = E+O+C2-10*C3,R5),
24 | pick(R5,R@@R = 10*C2+E-N-C1,R4),
25 | pick(R4,D,R3),
26 | pick(R3,Y@@Y = D+E-10*C1,_).
27 |
28 | testmoney:[]@=harness.
29 | testmoney<=harness.
30 | testmoney..{
31 | doAction() ->
32 | {solve(A,B,C)};
33 | stdout.outLine(A.show()<>"+"<>B.show()<>"="<>C.show()).
34 | }.
35 |
36 | main(_) ->
37 | checkUnit(testmoney).
38 | }.
39 |
--------------------------------------------------------------------------------
/BootCompiler/person.go:
--------------------------------------------------------------------------------
1 | person{
2 | place <~ { name:[]=>string }.
3 |
4 | person <~ { age:[]=>integer. spouse:[]=>person }.
5 |
6 | nowhere:[]$=place.
7 | nowhere..{
8 | name()=>"nowhere"
9 | }.
10 |
11 | noone:[]$=person.
12 | noone..{
13 | age()=>0.
14 | spouse()=>noone.
15 | }.
16 |
17 | person:[integer,person]$=person.
18 | person(A,S)..{
19 | Sp:person := S.
20 |
21 | spouse()=>Sp.
22 | age()=>A
23 | }.
24 |
25 | student <~ person.
26 | student <~ { studies:[]=>list[string] }.
27 |
28 | lazy:[]$=student.
29 | lazy<=noone.
30 | lazy..{
31 | studies()=>[]
32 | }.
33 |
34 | employee <~ person.
35 | employee <~ { work:[]=>string. salary:[]=>integer }.
36 |
37 | shiftless:[]$=employee.
38 | shiftless<=noone.
39 | shiftless..{
40 | work()=>"macdonalds".
41 | salary()=>23.
42 | }.
43 |
44 | married:[person+,person]{}.
45 | married(X,Y) :-
46 | X.spouse()=Y.
47 |
48 | check:[]{}.
49 | check() :-
50 | married(shiftless,_).
51 |
52 | }
--------------------------------------------------------------------------------
/go/serialize.go:
--------------------------------------------------------------------------------
1 | /*
2 | Serialization framework
3 | (c) 2004 F.G. McCabe
4 |
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation; either version 2 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 |
19 | Contact: Francis McCabe
20 | */
21 | go.serialize{
22 | serializer[T] <~ {
23 | serialize:[T,list[integer]] => list[integer].
24 | deserialize:[T-]-->list[integer]
25 | }.
26 | }
27 |
--------------------------------------------------------------------------------
/Engine/Headers/goobject.h:
--------------------------------------------------------------------------------
1 | /*
2 | Go Object related definitions for the Go! engine
3 | (c) 2000-2007 F.G.McCabe
4 |
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation; either version 2 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 |
19 | Contact: Francis McCabe
20 | */
21 |
22 | #ifndef _GO_OBJECT_H_
23 | #define _GO_OBJECT_H_
24 |
25 | #include "lock.h"
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/Doc/go-ref.lof:
--------------------------------------------------------------------------------
1 | \addvspace {10\p@ }
2 | \addvspace {10\p@ }
3 | \contentsline {figure}{\numberline {2.1}{\ignorespaces Part of {Go!}\xspace 's standard type lattice}}{36}{figure.2.1}
4 | \contentsline {figure}{\numberline {2.2}{\ignorespaces {Go!}\xspace 's {\texorpdfstring {\unhbox \voidb@x \hbox {\tt number}}{number}} type lattice}}{37}{figure.2.2}
5 | \addvspace {10\p@ }
6 | \addvspace {10\p@ }
7 | \addvspace {10\p@ }
8 | \addvspace {10\p@ }
9 | \addvspace {10\p@ }
10 | \addvspace {10\p@ }
11 | \contentsline {figure}{\numberline {8.1}{\ignorespaces A three-way package {\texorpdfstring {\unhbox \voidb@x \hbox {\tt import}}{import}}}}{145}{figure.8.1}
12 | \addvspace {10\p@ }
13 | \addvspace {10\p@ }
14 | \addvspace {10\p@ }
15 | \addvspace {10\p@ }
16 | \addvspace {10\p@ }
17 | \addvspace {10\p@ }
18 | \addvspace {10\p@ }
19 | \addvspace {10\p@ }
20 | \addvspace {10\p@ }
21 | \addvspace {10\p@ }
22 | \addvspace {10\p@ }
23 | \addvspace {10\p@ }
24 | \addvspace {10\p@ }
25 | \addvspace {10\p@ }
26 | \addvspace {10\p@ }
27 | \addvspace {10\p@ }
28 | \addvspace {10\p@ }
29 |
--------------------------------------------------------------------------------
/go/peer.go:
--------------------------------------------------------------------------------
1 | /*
2 | This package implements a local form of communication -- based on peer-to-peer communication.
3 | (c) 2004 F.G. McCabe
4 |
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation; either version 2 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 |
19 | Contact: Francis McCabe
20 | */
21 | go.peer{
22 | import go.io.
23 | import go.stdparse.
24 |
25 | peer[]<~handle[].
26 | peer(Host,
--------------------------------------------------------------------------------
/Doc/QuickRef/quick.lof:
--------------------------------------------------------------------------------
1 | \addvspace {10\p@ }
2 | \addvspace {10\p@ }
3 | \contentsline {figure}{\numberline {2.1}{\ignorespaces Part of {Go!}\xspace 's standard type lattice}}{22}{figure.2.1}
4 | \contentsline {figure}{\numberline {2.2}{\ignorespaces {Go!}\xspace 's {\texorpdfstring {\unhbox \voidb@x \hbox {\tt number}}{number}} type lattice}}{23}{figure.2.2}
5 | \addvspace {10\p@ }
6 | \addvspace {10\p@ }
7 | \addvspace {10\p@ }
8 | \addvspace {10\p@ }
9 | \addvspace {10\p@ }
10 | \addvspace {10\p@ }
11 | \contentsline {figure}{\numberline {8.1}{\ignorespaces A three-way package {\texorpdfstring {\unhbox \voidb@x \hbox {\tt import}}{import}}}}{103}{figure.8.1}
12 | \addvspace {10\p@ }
13 | \addvspace {10\p@ }
14 | \addvspace {10\p@ }
15 | \addvspace {10\p@ }
16 | \addvspace {10\p@ }
17 | \addvspace {10\p@ }
18 | \addvspace {10\p@ }
19 | \addvspace {10\p@ }
20 | \addvspace {10\p@ }
21 | \addvspace {10\p@ }
22 | \addvspace {10\p@ }
23 | \addvspace {10\p@ }
24 | \addvspace {10\p@ }
25 | \addvspace {10\p@ }
26 | \addvspace {10\p@ }
27 | \addvspace {10\p@ }
28 | \addvspace {10\p@ }
29 |
--------------------------------------------------------------------------------
/BootCompiler/cell.go:
--------------------------------------------------------------------------------
1 | /*
2 | * module to implement updateable cells
3 | */
4 |
5 | go.cell{
6 | cell[T] <~ { get:[]=>T. set:[T]* }.
7 | cell[_] <~ synchronized.
8 |
9 | cell:[T]$=cell[T].
10 | cell(I)..{
11 | V:symbol := __term(I).
12 |
13 | get()::__is(V,E) => E.
14 |
15 | set(N) -> __remove(V); V:=__term(N).
16 |
17 | show()::__is(V,E)=>"$"<>E.show().
18 | }.
19 |
20 | dynamic[T] <~ cell[list[T]].
21 | dynamic[T] <~ { add:[T]*. delete:[T]* }.
22 |
23 | dynamic:[list[T]]$=dynamic[T].
24 | dynamic(I) <= cell(I).
25 | dynamic(I:list[T]):dynamic[T]..{
26 | add(X) ->
27 | set(get()<>[X]).
28 |
29 | delete(X) ->
30 | set(remove(X,get())).
31 |
32 | LL:integer := len(I).
33 | }.
34 |
35 | remove:[T,list[T]]=>list[T].
36 | remove(_,[]) => [].
37 | remove(X,[X,..L]) => remove(X,L).
38 | remove(X,[A,..L]) => [A,..remove(X,L)].
39 |
40 | len:[list[t]]=>integer.
41 | len([]) => 0.
42 | len([_,..L]) => len(L)+1.
43 |
44 | (<>):[list[t],list[t]]=>list[t].
45 | []<>X=>X.
46 | [E,..X]<>Y=>[E,..X<>Y].
47 | }
--------------------------------------------------------------------------------
/Tests/synctest.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test various forms of synchronized actions
3 | */
4 |
5 | synctest{
6 | import go.io.
7 |
8 | OO[T] <~ { get:[]=>T. set:[T]* }.
9 |
10 | OO:[]@>OO[number].
11 | OO()..{
12 | bal:number := 0.
13 | get()=> valof{
14 | sync{
15 | valis bal
16 | }
17 | timeout (now()+0.34 -> valis -1)
18 | }.
19 | set(X) -> sync{
20 | bal := X
21 | }
22 | }.
23 |
24 | route1:[OO[number]]*.
25 | route1(Ob) ->
26 | sync(Ob){
27 | Ob.get()>0 -> Ob.set(Ob.get()-rand(4));stdout.outLine("Route 1 = "<>Ob.get().show())
28 | } timeout (now()+1.0 -> stdout.outLine("Route1 timed out"));
29 | delay(rand(2));
30 | route1(Ob).
31 |
32 | route2:[OO[number]]*.
33 | route2(Ob) ->
34 | sync(Ob){
35 | Ob.set(Ob.get()+rand(10));stdout.outLine("Route 2 = "<>Ob.get().show())
36 | };
37 | delay(rand(5));
38 | route2(Ob).
39 |
40 | main(_) ->
41 | O = OO();
42 | spawn{ route1(O) };
43 | route2(O).
44 | }
--------------------------------------------------------------------------------
/Agent/agent.gh:
--------------------------------------------------------------------------------
1 | /*
2 | Header files for agent
3 | (c) 1994-2001 Imperial College and F.G. McCabe
4 |
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation; either version 2 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 |
19 | Contact: Francis McCabe
20 | */
21 |
22 |
23 | callterm::= male(symbol) | female(symbol) |
24 | parent(symbol,symbol) | age(symbol,number) |
25 | ancestor(symbol,symbol) | likes(symbol,symbol).
26 |
--------------------------------------------------------------------------------
/GoCompiler/misc.go:
--------------------------------------------------------------------------------
1 | /* Miscellaneous support for the Go in Go compiler */
2 | misc{
3 | private
4 | count:integer := 0.
5 |
6 | genNew:[string]=>symbol.
7 | genNew(Prefix)::action{ count:=count+1 } => implode(Prefix<>count.show()).
8 |
9 | head:[list[t]]=>t.
10 | head([X,.._]) => X.
11 |
12 | tail:[list[t]]=>list[t].
13 | tail([_,..X]) => X.
14 |
15 | fileRoot:[string]=>string.
16 | fileRoot(f)::append(_,[`/,..T],f) => fileRoot(T).
17 | fileRoot(f)::append(T,[`.,.._],f) => fileRoot(T).
18 | fileRoot(f) => f.
19 |
20 | expand:[list[t],list[t]]=>list[list[t]].
21 | expand([],_) => [].
22 | expand(Str,Pre) => expnd(Str,[],Pre).
23 |
24 | private expnd:[list[t],list[t],list[t]]=>list[list[t]].
25 | expnd([],soFar,_) => [reverse(soFar)].
26 | expnd(Str,soFar,Pre) :: append(Pre,Tail,Str) => [reverse(soFar),..expand(Tail,Pre)].
27 | expnd([C,..S],soFar,Pre) => expnd(S,[C,..soFar],Pre).
28 |
29 | slashify:[list[string],string]=>string.
30 | slashify(L,S) => collapse(L,S).
31 |
32 | do <~ { do:[]* }.
33 | do:[]@=do.
34 | do..{
35 | do()->{}
36 | }.
37 |
38 | }.
39 |
--------------------------------------------------------------------------------
/mysql/go/mysql.go:
--------------------------------------------------------------------------------
1 | /*
2 | * A library module to give higher-level access to the mysql database
3 | * functions
4 | */
5 |
6 | (mysql)..{
7 | include "sys:go/stdlib.gof".
8 | include "sys:ext/mysql/libmysqlgo.gof".
9 |
10 | mysql(Host,User,Pass,Db){
11 | mem(Table,P) :- Candidates = valof{
12 | sync{
13 | Q = __mysql_query(Host,User,Pass,Db,
14 | "select * from "<>Table);
15 | valis _collectResults(Q)
16 | }
17 | },
18 | P in Candidates.
19 |
20 | query(Query,P) :- Candidates = valof{
21 | sync{
22 | Q = __mysql_query(Host,User,Pass,Db,Query);
23 | valis _collectResults(Q)
24 | }
25 | },
26 | P in Candidates.
27 |
28 | _collectResults(Q) => [Entry,.._collectResults(Q)] :-
29 | __mysql_fetchrow(Q,Entry).
30 | _collectResults(Q) => [] :- __mysql_freeresult(Q).
31 | }.
32 | }.
33 |
--------------------------------------------------------------------------------
/Tests/inner.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Test some aspects of inner classes
3 | */
4 | inner{
5 | import go.io.
6 | import go.unit.
7 |
8 | -- Basic cell type
9 | cl[T] <~ { g:[]=>T. p:[T]* }.
10 |
11 | combo[t] <~ { pr:[t]{}. cell:[t]@>cl[t] }.
12 |
13 | -- Basic cell class
14 | cl:[t] @> cl[t].
15 | cl(I)..{
16 | V:t := I.
17 |
18 | g()=>V.
19 |
20 | p(N) -> V:=N
21 | }.
22 |
23 | dl:[]@>cl[symbol].
24 | dl()..{
25 | p(_)->{}.
26 | }.
27 | dl()<=cl('a').
28 |
29 | inner:[]@=harness.
30 | inner<=harness.
31 | inner..{
32 | cb:[] @= combo[symbol].
33 | cb..{
34 | cell(S)<=cl(S). -- An inner class defined with a class rule only
35 |
36 | pr('a').
37 | }.
38 |
39 | doAction() ->
40 | CB = cb; -- this is stateless
41 | CC = cb.cell('a'); -- this is stateful
42 | { CC.g()=='a' }; -- this should succeed
43 | CC.p('c');
44 | stdout.outLine("CC = "<>CC.g().show());
45 | ( {CC.g()=='b'}
46 | onerror (
47 | E -> stdout.outLine("Test failed as expected, E="<>E.show())
48 | )
49 | ).
50 | }.
51 |
52 | main(_) ->
53 | checkUnit(inner).
54 | }
--------------------------------------------------------------------------------
/Tests/cases.go:
--------------------------------------------------------------------------------
1 | /*
2 | * A test of the case action
3 | */
4 |
5 | cases{
6 | import go.io.
7 | import go.unit.
8 | import go.stdparse.
9 |
10 | cases:[integer]@=harness.
11 |
12 | cases(_)<=harness.
13 | cases(L)..{
14 | doAction() ->
15 | I in iota(1,10) *>
16 | case I in (
17 | X::X
18 | stdout.outLine(X.show()<>" is less than "<>L.show())
19 | | 5 ->
20 | stdout.outLine("We have 5")
21 | | X ->
22 | stdout.outLine(X.show()<>" is not less than "<>L.show())
23 | );
24 | case (12,34) in (
25 | (12,10) -> stdout.outLine("Duh")
26 | | (12,34) -> stdout.outLine("Hooray")
27 | | (_,_) -> stdout.outLine("Boo")
28 | ).
29 |
30 | app:[list[t],list[t]]=>list[t].
31 | app(X,Y) => case X in (
32 | [] => Y
33 | |[E,..R] => [E,..app(R,Y)]
34 | ).
35 | doPred() :-
36 | app("1234","abc")="1234abc".
37 | }.
38 |
39 | main([]) ->
40 | checkUnit(cases(5)).
41 | main([N]) ->
42 | checkUnit(cases(naturalOf%%N)).
43 | }.
44 |
--------------------------------------------------------------------------------
/Headers/sslEscapes.h:
--------------------------------------------------------------------------------
1 | /*
2 | This defines the escapes that access the SSL interface
3 | (c) 2006 F.G.McCabe
4 |
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation; either version 2 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 |
19 | Contact: Francis McCabe
20 |
21 | */
22 |
23 | escape("__connectSSL",s_connectSSL,600,True,False,"F\1+OO","connect securely to remote host")
24 |
25 | escape("__acceptSSL",s_acceptSSL,601,True,False,"F\1+OO","accept secure connection")
26 |
27 |
28 |
--------------------------------------------------------------------------------
/BootCompiler/p.go:
--------------------------------------------------------------------------------
1 | /*
2 | * A simple module implementing a person class
3 | */
4 |
5 | org.go.person{
6 | import app.
7 |
8 | person[] ::= { name:()=>string, spouse:()=>person[], likes:(person[]){} }.
9 |
10 | purson(Name,Sp:person):person[]..{
11 | name()=>Name.
12 |
13 | likes(X) :- X.likes(this).
14 | spouse() => Sp.
15 |
16 | check(X) :- (par()-->X).
17 | }.
18 |
19 | noone:person[]..{
20 | name()=>"noone":-likes(this).
21 | name()=>"boo".
22 | spouse()=>this.
23 | likes(_):-false.
24 | }.
25 |
26 | student[] ::= { school:(()=>string) }.
27 | student[] <~ person[].
28 |
29 | student(Name:string,_) <= purson(Name,noone).
30 | student(N,School):student[]..{
31 | school()=>"nowhere" :- name()="noone".
32 | school()=>School :- \+name()="noone".
33 | -- likes(X) :- X.likes(this).
34 | -- name()=>N.
35 | -- check(X:person[]) :- X.check().
36 | -- spouse()=>purson.spouse(). -- :-spouse()!=noone.
37 | par() --> "hello", [X], { X in name() }.
38 |
39 | }.
40 |
41 | likes(X<~person[]) :- X.spouse()=noone.
42 |
43 | par(),"bye" --> "hello", [X], { X in noone.name() }.
44 | }
45 |
--------------------------------------------------------------------------------
/Tests/dynchurn.go:
--------------------------------------------------------------------------------
1 | dynchurn{
2 | import go.io.
3 | import go.stdparse.
4 | import go.dynamic.
5 | import go.unit.
6 |
7 | churn:[integer,integer]@>harness.
8 | churn(_,_) <= harness.
9 | churn(ThCount,LnCount)..{
10 | XX:dynamic[list[integer]] = dynamic([]).
11 |
12 | run:[integer]*.
13 |
14 | run(0)->stdout.outLine("XX left at "<>XX.ext().show()).
15 | run(C)::even(C) ->
16 | XX.delc(:dynTest[list[integer]]..{
17 | check(L) :-
18 | action{
19 | stdout.outLine("Testing element: "<>L.show())
20 | },
21 | listlen(L) rem 3==0.0.
22 | });
23 | run(C-1).
24 | run(C) ->
25 | XX.add(iota(1,C));
26 | stdout.outLine("XX now "<>XX.ext().show());
27 | run(C-1).
28 |
29 | even:[integer]{}.
30 | even(X) :- X rem 2==0.0.
31 |
32 | spawner:[integer,integer]=>list[thread].
33 | spawner(0,_)=>[].
34 | spawner(N,F)=>[spawn{run(N*F quot 2)},..spawner(N-1,F)].
35 |
36 | doAction() ->
37 | Th in spawner(ThCount,LnCount) *> waitfor(Th).
38 | }.
39 |
40 | main([]) -> checkUnit(churn(10,5)).
41 |
42 | main([C,F,.._]) -> checkUnit(churn(naturalOf%%C,naturalOf%%F)).
43 | }
--------------------------------------------------------------------------------
/go/CVS/Entries:
--------------------------------------------------------------------------------
1 | /.cvsignore/1.1.1.1/Sat Aug 2 22:19:56 2003//
2 | /acs.gh/1.1.1.1/Sat Aug 2 22:19:56 2003//
3 | /boot.go/1.1.1.1/Sat Aug 2 22:19:56 2003//
4 | /debug.go/1.1.1.1/Sat Aug 2 22:19:57 2003//
5 | /platform.go/1.1.1.1/Sat Aug 2 22:19:58 2003//
6 | /sort.go/1.1.1.1/Sat Aug 2 22:19:58 2003//
7 | /stdio.gh/1.1.1.1/Sat Aug 2 22:19:58 2003//
8 | /synchronized.go/1.1.1.1/Sat Aug 2 22:19:58 2003//
9 | /stdlib.go/1.2/Sat Sep 27 18:32:03 2003//
10 | /Makefile.am/1.3/Mon Dec 29 23:41:02 2003//
11 | /acsComms.go/1.2/Thu Oct 30 02:57:02 2003//
12 | /cell.go/1.2/Wed Dec 3 02:23:04 2003//
13 | /datelib.go/1.2/Sat Nov 29 07:12:27 2003//
14 | /dx.go/1.3/Mon Dec 1 17:51:33 2003//
15 | /dynamic.go/1.2/Tue Dec 9 02:29:30 2003//
16 | /loader.go/1.2/Tue Oct 28 04:17:04 2003//
17 | /profile.go/1.3/Mon Dec 1 17:50:28 2003//
18 | /scomms.go/1.2/Tue Apr 27 21:42:47 2004//
19 | /setlib.go/1.2/Wed Jan 7 06:14:41 2004//
20 | /stack.go/1.2/Wed Dec 3 02:25:52 2003//
21 | /stdparse.go/1.2/Fri Nov 28 06:42:15 2003//
22 | /xml.go/1.2/Mon Jan 5 01:42:33 2004//
23 | /debugger.go/1.3/Sat May 1 05:42:50 2004//
24 | /hash.go/1.4/Wed May 26 17:25:49 2004//
25 | /io.go/1.3/Sun Jun 27 17:25:09 2004//
26 | D
27 |
--------------------------------------------------------------------------------
/go/showable.go:
--------------------------------------------------------------------------------
1 | go.showable{
2 | import go.io.
3 |
4 | /* A small package to support a more optimized display of information */
5 |
6 | dispTree <~ { flatten:[string]=>string }.
7 |
8 | showable <~ { disp:[]=>dispTree. }.
9 |
10 | s:[string]@=dispTree.
11 | s(S)..{
12 | flatten(Tail)::append(S,Tail,X) => X.
13 | show()=>S.
14 | }.
15 |
16 | l:[list[string]]@=dispTree.
17 | l(L)..{
18 | flatten(Tail)::multiApp(L,Tail,X) => X.
19 |
20 | multiApp:[list[list[t]],list[t],list[t]]{}.
21 | multiApp([],S,S) :-- true.
22 | multiApp([St,..R],S0,S) :-- append(St,S1,S), multiApp(R,S0,S1).
23 | show()=>flatten([]).
24 | }.
25 |
26 | n:[list[dispTree]]@=dispTree.
27 | n(L)..{
28 | flatten(Tail) => fltn(L,Tail).
29 |
30 | fltn:[list[dispTree],string]=>string.
31 | fltn([],Tail) => Tail.
32 | fltn([E,..M],Tail) => E.flatten(fltn(M,Tail)).
33 | show()=>flatten([]).
34 | }.
35 |
36 | show:[showable]=>string.
37 | show(Tr)=>Tr.disp().flatten("").
38 |
39 | dispOut:[outChannel,dispTree]*.
40 | dispOut(O,s(Txt)) -> O.outStr(Txt).
41 | dispOut(O,l(L)) -> E in L *> O.outStr(E).
42 | dispOut(O,n(L)) -> E in L *> dispOut(O,E).
43 | }
--------------------------------------------------------------------------------
/macros/go.m4:
--------------------------------------------------------------------------------
1 | dnl NA_DETECT_GO(REQUIRED)
2 | dnl
3 | dnl Arguments
4 | dnl REQUIRED - required/optional
5 | dnl
6 | dnl Description:
7 | dnl Detect the Go! installation
8 | dnl
9 | dnl Defines
10 | dnl GODIR - installation directory
11 | dnl
12 | dnl Notes
13 | dnl If REQUIRED is set to 'required' and the package
14 | dnl is not found, a fatal error message will be issued
15 | dnl and configure will exit.
16 |
17 | AC_DEFUN(NA_DETECT_GO,[
18 |
19 | na_required=$1
20 |
21 | AC_ARG_WITH(go,
22 | [ --with-go[=dir] indicate location of the go installation],
23 | [na_go=${withval}],
24 | [na_go=${GODIR}]
25 | )
26 |
27 | [na_parentprefix=`echo "$prefix"|sed -e 's%\(.\)/[^/]*/*$%\1%'`]
28 |
29 | na_searchpath=${na_go}/bin:${PATH}:/opt/go/bin:$prefix/bin:$na_parentprefix/go/bin
30 | AC_PATH_PROG(na_go,go,[not found],$na_searchpath)
31 |
32 | if test "$na_go" = "not found" ; then
33 | if test "$na_required" = "required" ; then
34 | echo
35 | AC_MSG_ERROR([go not found in $na_searchpath
36 | Run configure with --with-go to specify the Go
37 | installation directory
38 | ])
39 | fi
40 | fi
41 |
42 | GODIR=`echo $na_go | sed -e s%/bin/go$%%`
43 | AC_SUBST(GODIR)
44 |
45 | ])
--------------------------------------------------------------------------------
/Tests/msgrace.go:
--------------------------------------------------------------------------------
1 | msgrace{
2 | -- threads sending a lot of messages to each other
3 |
4 | import go.io.
5 | import go.unit.
6 | import go.stdparse.
7 | import go.mbox.
8 |
9 | msg::= add(integer) | subtract(integer) .
10 |
11 | plip:[dropbox[msg]]*.
12 | plip(T) ->
13 | -- delay(rand(0.5));
14 | ( irand(1000) rem 3 == 0.0 ?
15 | T.post(subtract(9))
16 | | T.post(add(8)));
17 | plip(T).
18 |
19 | plop:[integer,integer,mailbox[msg]]*.
20 | plop((soFar::soFar<0),_,_) -> stdout.outLine("bottomed out").
21 | plop(soFar,(tgt::soFar>tgt),_) -> stdout.outLine("topped out with "<>soFar.show()).
22 | plop(soFar,tgt,Bx) ->
23 | stdout.outLine("current soFar="<>soFar.show());
24 | case Bx.next() in (
25 | add(C) -> plop(soFar+C,tgt,Bx)
26 | | subtract(C) -> plop(soFar-C,tgt,Bx)
27 | ).
28 |
29 | race:[integer]@=harness.
30 | race(_)<=harness.
31 | race(T)..{
32 | doAction()->
33 | H = mailbox();
34 | spawn{ plip(H.dropbox()) };
35 | waitfor(spawn{ plop(10,T,H)}).
36 | }.
37 |
38 | main([]) ->
39 | checkUnit(race(100)).
40 | main([N]) ->
41 | checkUnit(race(naturalOf%%N)).
42 | }
43 |
--------------------------------------------------------------------------------
/graph/matrix.go:
--------------------------------------------------------------------------------
1 | graph.matrix{
2 | -- Graphical matrix manipulations
3 | import go.io.
4 |
5 | matrix <~ {
6 | inverse:[]=>matrix.
7 | apply:[float,float]=>(float,float).
8 | mult:[matrix]=>matrix.
9 | det:[]=>float.
10 | }.
11 |
12 | gmtx:[float,float,float,float,float,float]@=matrix.
13 | gmtx(a11,a12,a21,a22,a31,a32)..{
14 | apply(u,v) => (u*a11+v*a21+a31,u*a21+v*a22+a32).
15 |
16 | mult(gmtx(b11,b12,b21,b22,b31,b32))=>
17 | gmtx(a11*b11+a12*b21,a11*b12+a12*b22,a21*b11+a22*b21,a21*b12+a22*b22,
18 | a31*b11+a32*b21+b31,a31*b12+a32*b22+b32).
19 |
20 | inverse()=>valof{
21 | D = det();
22 | (D==0.0?
23 | raise error("inverse",'eINVAL'));
24 | valis gmtx(a22/D,-a12/D,-a21/D,a11/D,
25 | (a21*a32-a22*a31)/D,(a12*a31-a11*a32)/D)
26 | }.
27 |
28 | det() => a11*a22-a12*a21.
29 | }.
30 |
31 | main(_) ->
32 | T = gmtx(1.0,5.0,1.0,1.0,0.0,-3.0);
33 | stdout.outLine("T = "<>T.show());
34 | I = T.inverse();
35 | stdout.outLine("I = "<>I.show());
36 | stdout.outLine("TI = "<>T.mult(I).show());
37 | stdout.outLine("IT = "<>I.mult(T).show());
38 | stdout.outLine("T.apply(3,4)="<>T.apply(3.0,4.0).show()).
39 | }
--------------------------------------------------------------------------------
/go/cell.go:
--------------------------------------------------------------------------------
1 | /*
2 | Standard program for implementing dynamic programs
3 | (c) 2004-2005 F.G. McCabe
4 |
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation; either version 2 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 |
19 | Contact: Francis McCabe
20 | */
21 | go.cell{
22 | cell[T] <~ { get:[]=>T. set:[T]* }.
23 |
24 | cell:[T]@>cell[T].
25 | cell(I:T)..{
26 | V:symbol := __term(I).
27 |
28 | get()::__is(V,E) => E.
29 |
30 | set(N) -> sync{ __remove(V); V:=__term(N)}.
31 |
32 | show()::__is(V,E)=>"$"<>E.show().
33 | }.
34 | }
35 |
--------------------------------------------------------------------------------