Eli   Documents

General Information

 o Eli: Translator Construction Made Easy
 o Global Index
 o Frequently Asked Questions
 o Typical Eli Usage Errors

Tutorials

 o Quick Reference Card
 o Guide For new Eli Users
 o Release Notes of Eli
 o Tutorial on Name Analysis
 o Tutorial on Scope Graphs
 o Tutorial on Type Analysis
 o Typical Eli Usage Errors

Reference Manuals

 o User Interface
 o Eli products and parameters
 o LIDO Reference Manual
 o Typical Eli Usage Errors

Libraries

 o Eli library routines
 o Specification Module Library

Translation Tasks

 o Lexical analysis specification
 o Syntactic Analysis Manual
 o Computation in Trees

Tools

 o LIGA Control Language
 o Debugging Information for LIDO
 o Graphical ORder TOol

 o FunnelWeb User's Manual

 o Pattern-based Text Generator
 o Property Definition Language
 o Operator Identification Language
 o Tree Grammar Specification Language
 o Command Line Processing
 o COLA Options Reference Manual

 o Generating Unparsing Code

 o Monitoring a Processor's Execution

Administration

 o System Administration Guide

Mail Home

Library Reference

Previous Chapter Next Chapter Table of Contents


Character String Storage

This module provides both temporary and persistent storage for arbitrary-length character strings. Strings stored by the module can be identified by either a pointer or an integer. The set of persistent strings can be written at any time to a text file as either a sequence of lines, one string per line in the form of a C string denotation, or as the C definition of an initialized data structure.

#include "csm.h"

int stostr(char *c, int l)
char *StringTable(int i);
char *NoStr
int NoStrIndex;
int numstr;

ObstackP Csm_obstk;
char *CsmStrPtr;

char *prtstcon(FILE *d, char *p)

savestr(FILE *d)

dmpstr(FILE *d)

Stostr stores a character string c of length l in the memory, returning the index of the string. StringTable is a macro that delivers a pointer to a null-terminated string, given the index of that string established by stostr. The number of strings currently stored is given by numstr (initially 0); thus numstr-1 is the largest index that can be used as an argument to StringTable.

`csm.h' defines the constant NoStr to be a unique character pointer that represents no string. It also defines NoStrIndex to be a unique string index that will never be used to represent a string. The string indexed by NoStrIndex contains no characters.

Csm_obstk is a region that can hold sets of strings. It can be managed by the operations of the memory object allocator (see Memory Object Management). The actual characters of the strings stored by stostr are stored in Csm_obstk. CsmStrPtr is a pointer that can be set by a client of the character storage module to point to a string in Csm_obstk. When this pointer is passed to stostr, stostr assumes that another copy of the string need not be stored.

Prtstcon prints the string pointed to by p on the current line of file d. The string is printed as a C string constant with the quotes omitted. This function can be omitted from the module by compiling with the C flag -DNOPRINT. Dmpstr prints the set of strings StringTable(0) through StringTable(numstr-1) on file d as a sequence of lines. This function can also be omitted from the module by compiling with the C flag -DNOPRINT.

Savestr writes the current state of the module on file d, in the form of C initialized variables. Only the strings stored by stostr will be written to d. This file can be used to create a copy of the module initialized to the current state by naming it `csmtbl.h' and recompiling the module. The save function is available only if the module was compiled with the C flag -DSAVE, and if the printing routines were not omitted.


Previous Chapter Next Chapter Table of Contents