XCLE



Parsing module

Instructions manual


XCLE: eXtensible Concatenative Language Engine
Copyright (C) 2000-2006 Yann LANDRIN-SCHWEITZER a.k.a. Varkhan


This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Author: Yann LANDRIN-SCHWEITZER
Contact: varkhan@varkhan.net
Homepage: http://www.varkhan.net/


Parsing context definition


Function XCLE_ParseCtxAlloc

XCLE_ParseCtx XCLE_ParseCtxAlloc(void) ;
Creates a new parsing context.

Returns:
NULL: if memory allocation could not be performed
else a new XCLE_ParseCtx object.




Function XCLE_ParseCtx_DescByName

const char * XCLE_ParseCtx_DescByName(XCLE_ParseCtx contx, char * str) ;
Finds a description for a Code name, looking for a definition in registered tables.

Args:
contx: parsing context
str: string to look up in the tables


Returns:
NULL: if the string or parsing context were NULL, or the string was not found in the tables
else a Code of name 'str', built from the related definition.


NOTE:
Use XCLE_CodeRegister to register instructions before calling XCLE_CodeByName.




Function XCLE_ParseCtx_CodeByName

XCLE_Code XCLE_ParseCtx_CodeByName(XCLE_ParseCtx contx, char * str) ;
Creates a Code object by its name, looking for a definition in registered tables.

Args:
contx: parsing context
str: string to look up in the tables


Returns:
NULL: if the string or parsing context were NULL, or the string was not found in the tables
else a Code of name 'str', built from the related definition.


NOTE:
Use XCLE_CodeRegister to register instructions before calling XCLE_CodeByName.





Registry and Dynamic Loading


Function XCLE_CodeRegister

unsigned long XCLE_CodeRegister(XCLE_ParseCtx contx, char * name, XCLE_CodeDef * table, unsigned long tablesize) ;
Registers a primitives module.

Args:
contx: parsing context
name: module name
table: table of primitives definitions
tablesize: size of the definitions table


Returns:
-1: if the parsing context, the module name or the table were NULL
0: if the table was empty
else the number of modules registered.


Errors:
ENOMEM: if a reallocation failed
EINVAL: if the context was not properly defined, or the module name was NULL
EINVAL: if the table was NULL or empty



Function XCLE_CodeUnregister

unsigned long XCLE_CodeUnegister(XCLE_ParseCtx contx, char * name) ;
Unregisters a primitives module.

Args:
contx: parsing context
name: module name


Returns:
-1: if the parsing context or the module name were NULL
else the number of modules registered.


Errors:
ENOMEM: if a reallocation failed
EINVAL: if the context was not properly defined
EINVAL: if the module name was NULL or could not be found



Function XCLE_CodeLoad

unsigned long XCLE_CodeLoad(XCLE_ParseCtx contx, char * module) ;
Registers instruction definitions from a module file.

Args:
contx: parsing context
module: file name of the module


Returns:
-1: if the parsing context was NULL, or the module was invalid
else the size of the table.


Errors:
ENOMEM: if a reallocation failed
ENOENT: if the module was not found
EINVAL: if the context was not properly defined or the module structure invalid

NOTE:
This loading interface asks for two symbol names to be defined in modules (shared
objects, or dynamically loaded libraries):
unsigned long XCL_Registry_Vers: a version identifier produced by XCLE_MAKEVERSIONID
unsigned long XCL_Registry_Size: the number of CodeDef objects defined by the module
XCLE_CodeDef XCL_Registry_Table: a table of CodeDef objects defining the module contents
To prevent loading of modules compiled with incompatibles versions of XCLE, the module is
loaded only if XCL_Registry_Vers matches XCLE_versionid() in their first two bytes.
Module developers should use the macro XCLE_MAKEVERSIONID with the major, minor and
release version number of the XCLE library they use to produce XCL_Registry_Vers.





Parsing


Function XCLE_ObjectParse

XCLE_Object XCLE_ObjectParse(XCLE_ParseCtx contx, char * str, unsigned long * off) ;
Creates an object, from a character string object representation.

Args:
contx: parsing context
str: string to parse
off: offset pointer in the string indicating where to begin (or NULL)


Returns:
NULL: if a syntax error occurred or the end of the string was reached
else the next parsed XCLE_Object.


Errors:
EINVAL: if a syntax error occurred
ENOMEM: if no memory was available



Function XCLE_ListParse

XCLE_List XCLE_ListParse(XCLE_ParseCtx contx, char * str, unsigned long * off) ;
Parses a string into a list of objects.

Args:
contx: parsing context
str: string to parse
off: offset pointer in the string indicating where to begin (or NULL)


Returns:
NULL: if a syntax error occurred, or no object was found
else an XCLE_List of all recognised XCLE_Objects.


Errors:
EINVAL: if a syntax error occurred
ENOMEM: if no memory was available




Generated by textdoc2html - 2006-02-22