Pajdeg  0.2.2
Pajdeg
Files | Macros | Typedefs | Enumerations | Functions | Variables

An operator for a given symbol or outcome in a state. More...

Files

file  PDOperator.h
 

Macros

#define PDOperatorSymbolGlobRegular   0
 PDF regular character.
 
#define PDOperatorSymbolGlobWhitespace   1
 PDF whitespace character.
 
#define PDOperatorSymbolGlobDelimiter   4
 PDF delimiter character.
 
#define PDOperatorSymbolExtNumeric   8
 Numeric value.
 
#define PDOperatorSymbolExtFake   16
 "Fake" symbol
 
#define PDOperatorSymbolExtEOB   32
 End of buffer (usually synonymous with end of file) symbol.
 
#define PDSymbolUpdateNumeric(numeric, real, c, first_character)
 
#define PDSymbolDetermineNumeric(numeric, real, c, sym, len)
 

Typedefs

typedef struct PDOperatorPDOperatorRef
 

Enumerations

enum  PDOperatorType {
  PDOperatorPushState = 1, PDOperatorPushWeakState, PDOperatorPopState, PDOperatorPopVariable,
  PDOperatorPopValue, PDOperatorPushEmptyString, PDOperatorPushResult, PDOperatorPushComplex,
  PDOperatorStoveComplex, PDOperatorPullBuildVariable, PDOperatorPushbackSymbol, PDOperatorPushbackValue,
  PDOperatorPopLine, PDOperatorReadToDelimiter, PDOperatorMark, PDOperatorPushMarked,
  PDOperatorNOP, PDOperatorBreak
}
 

Functions

void PDOperatorSymbolGlobSetup ()
 
char PDOperatorSymbolGlobDefine (char *str)
 
PDOperatorRef PDOperatorCreateFromDefinition (const void **defs)
 
void PDOperatorCompileStates (PDOperatorRef op)
 

Variables

char * PDOperatorSymbolGlob
 
char * PDOperatorSymbolGlobHex
 
char * PDOperatorSymbolGlobDehex
 
char * PDOperatorSymbolGlobEscaping
 

Detailed Description

An operator for a given symbol or outcome in a state.

Operators are either tied to some symbol in a state, or to one of the fallback types (numeric, delimiter, and the all-accepting). They define some form of action that should occur, and may optionally include a "next" operator, which is executed directly following the completion of the current operator's action.

Note
If an operator pushes a state, its action will be regarded as ongoing until the pushed state is poppsed again.

Macro Definition Documentation

#define PDSymbolDetermineNumeric (   numeric,
  real,
  c,
  sym,
  len 
)
Value:
do { \
for (i = len-1; numeric && i >= 0; i--) { \
c = sym[i]; \
PDSymbolUpdateNumeric(numeric, real, c, i==0); \
} \
} while (0)
long PDInteger
Definition: PDDefines.h:184
#define PDSymbolUpdateNumeric(numeric, real, c, first_character)
Definition: PDOperator.h:109

Set numeric and real for the given symbol over the given length.

Parameters
numericThe numeric boolean.
realThe real boolean.
cThe character.
symThe symbol buffer.
lenThe length of the symbol.
#define PDSymbolUpdateNumeric (   numeric,
  real,
  c,
  first_character 
)
Value:
numeric &= ((c >= '0' && c <= '9') \
|| \
(first_character && (c == '-' || c == '+')) \
|| \
(! real && (real |= c == '.')))

Update the numeric and real booleans based on the character.

Parameters
numericThe numeric boolean.
realThe real boolean.
cThe character.
first_characterWhether or not this is the first character.

Typedef Documentation

typedef struct PDOperator* PDOperatorRef

An operator.

Enumeration Type Documentation

Operator type.

Pajdeg's internal parser is configured using a set of states and operators. Operators are defined using a PDOperatorType, and an appropriate unioned argument.

See also
pd_pdf_implementation.h
Enumerator
PDOperatorPushState 

Pushes another state; e.g. "<" pushes dict_hex, which on seeing "<" pushes "dict".

PDOperatorPushWeakState 

Identical to above, but does not 'retain' the target state, to prevent retain cycles (e.g. arb -> array -> arb -> ...)

PDOperatorPopState 

Pops back to previous state.

PDOperatorPopVariable 

Pops entry off of results stack and stores as an attribute of a future complex result.

PDOperatorPopValue 

Pops entry off of results stack and stores in variable stack, without including a variable name.

PDOperatorPushEmptyString 

Pushes an empty string onto the results stack.

PDOperatorPushResult 

Pushes current symbol onto results stack.

PDOperatorPushComplex 

Pushes object of type description "key" with variables (if any) as attributes onto results stack.

PDOperatorStoveComplex 

Pushes a complex onto build stack rather than results stack (for popping as a chunk of objects later)

PDOperatorPullBuildVariable 

Takes build stack as is, and stores it as if it was a popped variable.

PDOperatorPushbackSymbol 

Pushes the scanned symbol back onto the symbols stack, so that it is re-read the next time a symbol is popped from the scanner.

PDOperatorPushbackValue 

Pushes the top value on the stack onto the symbols stack as if it were never read.

PDOperatorPopLine 

Read to end of line.

PDOperatorReadToDelimiter 

Read over symbols and whitespace until a delimiter is encountered.

PDOperatorMark 

Mark current position in buffer for popping as is into results later.

PDOperatorPushMarked 

Push everything from mark to current position in buffer as results.

PDOperatorNOP 

Do nothing.

PDOperatorBreak 

Break (presuming breakpoint is properly placed)

Function Documentation

void PDOperatorCompileStates ( PDOperatorRef  op)

Compile all states referenced by the operator.

See also
PDStateCompile
Parameters
opThe operator.
PDOperatorRef PDOperatorCreateFromDefinition ( const void **  defs)

Create a PDOperatorRef chain based on a definition in the form of NULL terminated arrays of operator types followed by (if any) arguments of corresponding types.

Parameters
defsDefinitions, null terminated.
Todo:
CLANG doesn't like homemade retaining
char PDOperatorSymbolGlobDefine ( char *  str)

Define the given symbol. Definitions detected are delimiters, numeric (including real) values, and (regular) symbols.

void PDOperatorSymbolGlobSetup ( )

Set up the global symbol table.

Variable Documentation

char* PDOperatorSymbolGlob

Global symbol table, a 256 byte mapping of ASCII characters to their corresponding PDF symbol type as defined in the PDF specification (v 1.7).

char* PDOperatorSymbolGlobDehex

Global de-HEX table, a 16 (NOT 256) byte mapping of 0 through 15, where 0..9 return '0'..'9' and 10..15 return 'A'..'F'

char* PDOperatorSymbolGlobEscaping

Global escape table, a 256 byte mapping of ASCII characters to 1 for "no escape", 0 for "escape as code", and a character for "escape using this escape code".

char* PDOperatorSymbolGlobHex

Global HEX table, a 256 byte mapping of ASCII characters to their corresponding numeric values according to the hexademical system.