Logiweb(TM)

11.11 testmachine: an example of a Logiweb machine

Prev Up Next Page 388 of 800 Search internet


The testmachine page defines a Logiweb machine which exercises the extension mechanism of the Logiweb Abstract Machine (lgwam). A numbered version of the testmachine.lgs source text is included below. Also see the original, unnumbered lgs file, the main pdf, and the document root.

     1	"";;01CA9680910201CFF3348602C21BF1B0E67EFD09308C92EAB6BBD8BB0806
     2	""P testmachine
     3	
     4	""R check
     5	""R Peano
     6	""R base
     7	""R test
     8	
     9	""D 0
    10	module1
    11	handler1
    12	handler2
    13	machine1 ( " )
    14	machine2 ( " )
    15	request1 ( " )
    16	
    17	""B
    18	page ( ""N , ""C )
    19	title "Test machine"
    20	bib "
    21	@techreport{appendix,
    22	  author    = {Klaus Grue},
    23	  year      = {2008},
    24	  title     = {Test machine - appendix},
    25	  institution={Logiweb},
    26	  note      = {\href{\lgwBlockRelay \lgwBlockThis /page/appendix.pdf}{%
    27	\lgwBreakRelay \lgwBreakThis /page/appendix.pdf}}}
    28	"
    29	main text "
    30	\title{Test machine}
    31	\author{Klaus Grue}
    32	\maketitle
    33	\tableofcontents
    34	\section{Definition of test machine}
    35	
    36	The test1 machine with handler "[[ handler1 ]]" defines a new request "[[ request1 ( *** ) ]]" using an extend request and then exercises the new request.
    37	
    38	\begin{quote}
    39	
    40	\noindent "[[ value define module1 as show "
    41	#define TRUE 1
    42	#define FALSE 0
    43	#include 
    44	int lgw2dll=TRUE;
    45	unsigned char buffer[]=""!World\n""!;
    46	int bufferpnt;
    47	int trigger(int c){
    48	  if(lgw2dll){
    49	    if(c<0){lgw2dll=FALSE;bufferpnt=0;}else{printf(""!%c""!,c);return 0;}}
    50	  if(buffer[bufferpnt]==0) return -1;
    51	  return buffer[bufferpnt++];}
    52	" end show end define ]]"
    53	
    54	\noindent "[[ value define request1 ( x ) as << quote request1 ( x ) end quote head ,, x >> end define ]]"
    55	
    56	\noindent "[[ value define handler1 as map ( \ x . machine1 ( x ) ) end define ]]"
    57	
    58	\noindent "[[ value define machine1 ( x ) as <<
    59	
    60	extend request ( request1 ( true ) , module1 ) ,,
    61	
    62	request1 ( show "Hello" end show ) ,,
    63	
    64	exec request ( true , handler2 ) >> end define ]]"
    65	
    66	\noindent "[[ value define handler2 as map ( \ x . machine2 ( x ) ) end define ]]"
    67	
    68	\noindent "[[ value define machine2 ( x ) as newline
    69	
    70	if x atom then << write request ( "Not found" ) >> else newline
    71	
    72	if .not. x head r= request1 ( true ) then machine2 ( x tail ) else newline
    73	
    74	<< write request ( x head tail head ) ,, quit request ( 0 ) >> end define ]]"
    75	
    76	\item "[[ execute define "test1" as << handler1 >> end define ]]"
    77	
    78	\end{quote}
    79	
    80	For more, see \cite{appendix}.
    81	\bibliography{./page}
    82	"
    83	appendix "
    84	\title{Combinations - appendix}
    85	\author{A. U. Thor}
    86	\maketitle
    87	\tableofcontents
    88	\section{\TeX\ definitions}
    89	\begin{statements}
    90	
    91	\item "[[ tex show define request1 ( x ) as "
    92	r_1 ( "[ x ]"
    93	)" end define ]]"
    94	
    95	\item "[[ tex show define module1 as "
    96	m_1" end define ]]"
    97	
    98	\item "[[ tex show define handler1 as "
    99	h_1" end define ]]"
   100	
   101	\item "[[ tex show define machine1 ( x ) as "
   102	M_1 ( "[ x ]"
   103	)" end define ]]"
   104	
   105	\end{statements}
   106	"
   107	end page
   108	
   109	
   110	
   111	

Prev Up Next Page 388 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05