*** empty log message ***
This commit is contained in:
		@ -1,49 +1,47 @@
 | 
				
			|||||||
.title ASEAWK
 | 
					.title ASEAWK
 | 
				
			||||||
 | 
					
 | 
				
			||||||
== ASEAWK ==
 | 
					== ASEAWK ==
 | 
				
			||||||
ASE provides an embeddable interpreter of a dialect of the AWK programming language. The language implemented is slightly different from {the version developed by Brian W. Kernighan, http://cm.bell-labs.com/cm/cs/awkbook/index.html} and has been adjusted to the author's preference.
 | 
					ASE provides an embeddable processor of a dialect of the AWK programming language. The language implemented is slightly different from {the version developed by Brian W. Kernighan, http://cm.bell-labs.com/cm/cs/awkbook/index.html} and has been adjusted to the author's preference.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
=== User Guide ===
 | 
					Embedding a processor requires the following basic steps.
 | 
				
			||||||
 | 
					 | 
				
			||||||
Embedding the interpreter needs one or more header files to be included. 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[[
 | 
					[[[
 | 
				
			||||||
* ase/awk/awk.h - exports most of the data types and functions for basic embedding. 
 | 
					* Create a processor instance
 | 
				
			||||||
 | 
					* Parse an AWK script
 | 
				
			||||||
 | 
					* Run the script parsed
 | 
				
			||||||
 | 
					* Destroy the instance
 | 
				
			||||||
]]]
 | 
					]]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Two more header files can be included depending on the need.
 | 
					The following code fragment illustrates the basic steps.
 | 
				
			||||||
[[[
 | 
					 | 
				
			||||||
* ase/awk/val.h - exports data types and functions to manipulate the AWK values.
 | 
					 | 
				
			||||||
* ase/awk/map.h - exports data types and functions to access the named variable holder.
 | 
					 | 
				
			||||||
]]]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
=== ABC ===
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
An awk object is created with ase_awk_open. The function requires a set of system primitive functions to be passed.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The object created with ase_awk_open should be destroyed with ase_awk_close when no longer needed.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
{{{
 | 
					{{{
 | 
				
			||||||
	ase_awk_t* awk;
 | 
					1) #include <ase/awk/awk.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	awk = ase_awk_open ();
 | 
					2) ase_awk_t* awk;
 | 
				
			||||||
 | 
					3) awk = ase_awk_open (...);
 | 
				
			||||||
	if (ase_awk_parse (awk) == -1)
 | 
					4) if (ase_awk_parse (awk, ...) == -1)
 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
        /* parse error */
 | 
					        /* parse error */
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
   else
 | 
					   else
 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
		if (ase_awk_run (awk) == -1)
 | 
					5)     if (ase_awk_run (awk, ...) == -1)
 | 
				
			||||||
       {
 | 
					       {
 | 
				
			||||||
           /* run-time error */
 | 
					           /* run-time error */
 | 
				
			||||||
       }
 | 
					       }
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					6)  ase_awk_close (awk);
 | 
				
			||||||
	ase_awk_close (awk);
 | 
					 | 
				
			||||||
}}}
 | 
					}}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(((
 | 
				
			||||||
 | 
					* Most of the functions and data types needed are defined in the header file <ase/awk/awk.h>. 
 | 
				
			||||||
 | 
					* ase_awk_t represents the processor.
 | 
				
			||||||
 | 
					* ase_awk_open creates the processor instance.
 | 
				
			||||||
 | 
					* ase_awk_parse parses an AWK script.
 | 
				
			||||||
 | 
					* ase_awk_run executes the script parsed.
 | 
				
			||||||
 | 
					* ase_awk_close destroys the processor instance.
 | 
				
			||||||
 | 
					)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
=== Primitive Functions ===
 | 
					=== Primitive Functions ===
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ase_awk_open requires a set of primitive functions to be passed. This set include pointers to the system primitive functions for system dependent operation such as memory allocation, string formatting, etc.
 | 
					ase_awk_open requires a set of primitive functions to be passed. This set include pointers to the system primitive functions for system dependent operation such as memory allocation, string formatting, etc.
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * $Id: doc.awk,v 1.11 2007-02-17 14:22:03 bacon Exp $
 | 
					 * $Id: doc.awk,v 1.12 2007-02-20 05:40:11 bacon Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * {License}
 | 
					 * {License}
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@ -145,6 +145,17 @@ header && !/^\.[[:alpha:]]+[[:space:]]/ {
 | 
				
			|||||||
				mode = 2;
 | 
									mode = 2;
 | 
				
			||||||
				list_count = 0;
 | 
									list_count = 0;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								else if (/\(\(\(/)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if (para_started)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										print "</p>";
 | 
				
			||||||
 | 
										para_started = 0;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									print "<ol>";
 | 
				
			||||||
 | 
									mode = 3;
 | 
				
			||||||
 | 
									list_count = 0;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (!para_started > 0) 
 | 
									if (!para_started > 0) 
 | 
				
			||||||
@ -205,6 +216,30 @@ header && !/^\.[[:alpha:]]+[[:space:]]/ {
 | 
				
			|||||||
			print_text ($0);
 | 
								print_text ($0);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						else if (mode == 3)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (/^\)\)\)$/)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								# )))
 | 
				
			||||||
 | 
								print "</li>";
 | 
				
			||||||
 | 
								print "</ol>";
 | 
				
			||||||
 | 
								mode = 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else if (/^\* [^[:space:]]+/)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								gsub ("<", "\\<");
 | 
				
			||||||
 | 
								gsub (">", "\\>");
 | 
				
			||||||
 | 
								if (list_count > 0) print "</li>";
 | 
				
			||||||
 | 
								print "<li>";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								print_text (substr ($0, 3, length($0)-2));
 | 
				
			||||||
 | 
								list_count++;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								print_text ($0);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
END {
 | 
					END {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user