Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

TextAsmScanner Class Reference

This class implements the VM plaintext assembly scanner. More...

#include <tasm-scanner.h>

Inheritance diagram for TextAsmScanner:

Inheritance graph
[legend]
Collaboration diagram for TextAsmScanner:

Collaboration graph
[legend]
List of all members.

Public Types

enum  TokID {
  T_EOF = 0, T_pop = 258, T_symbols, T_locations,
  T_program, T_info, TS_namespace, TS_class,
  TS_base, TS_baseent, TS_varent, TS_size,
  TS_virtual, TS_vtable, TS_symref, TS_vglobal,
  TS_pglobal, TS_symbols, TS_funcsym, TS_varsym,
  TS_globvar, TP_slabel, TP_mlabel, TP_rlabel,
  TI_abivers
}

Public Member Functions

 TextAsmScanner ()
 Construct text assembly scanner.

 ~TextAsmScanner ()
 Destroy text assembly scanner and all (allocated and zombie) tokens.

int NErrors () const
 Get the number of lexer errors.

VM::InstructionStorageInsnStorage ()
 Used to get insn_storage.


Static Public Member Functions

const char * TokID2String (TokID t)
 Return string representation of token ID.


Public Attributes

VM::ProgramStorage::Functioninsn_storage

Private Member Functions

void reset ()
 Scanner reset [overriding virtual].

TokenEntryAllocTokenEntry ()
 Important: Override token entry allocation routine.

char * _ParseNameStr (const char *str, const char *end)
 Parse name string.

template<typename T> const char * _ParseInt (T *ret, const char *str, char prefix='\0')
 Overloaded integer parsing function.

template<typename T> const char * _ParseInt0 (T *ret, const char *str)
 Special version which will return 0 if value is not present.

template<typename T> const char * _ParseFloat (T *ret, const char *str)
 Overloaded float parsing function.

const char * _ParseTypeSpec (Token::Type *ts, const char *str)
 Parse type spec.

void _CheckInstAllowed_Failed ()
 Internally used by _CheckInstAllowed().

bool _CheckInstAllowed ()
 Check if an instruction may be specified now. Returns 0 if not.

 TextAsmScanner (const TextAsmScanner &)
 Do not use.

void operator= (const TextAsmScanner &)
 Do not use.


Friends

int TASM_lex (void *)

Detailed Description

This class implements the VM plaintext assembly scanner.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
Note the use of the TASM_ prefix for the base class from scannerbase.h.

NOTE: This class is not in a namespace as it makes big trouble to put a flex lexer into a namespace.

Definition at line 50 of file tasm-scanner.h.


Member Enumeration Documentation

enum TextAsmScanner::TokID
 

This are the token identifiers. Do not forget to keep _TokID2String() in sync.

Enumeration values:
T_EOF  end of input (must be 0)
T_pop  read ";"; pop state
T_symbols  symbol / object desc
T_locations  location description
T_program  program instruction section
T_info  info section
TS_namespace  str_val: NAME
TS_class  str_val: NAME
TS_base 
TS_baseent 
TS_varent  [str_val: NAME]
TS_size 
TS_virtual 
TS_vtable  vtable block begin
TS_symref  vtable block entry
TS_vglobal  (Token info: none)
TS_pglobal  (Token info: none)
TS_symbols  number of symbol entries (TS_*sym)
TS_funcsym  str_val: fname; function symbol
TS_varsym  str_val: NAME; variable symbol
TS_globvar  (Token info: none); global block entry
TP_slabel  str_val: NAME; string label
TP_mlabel  codemark label
TP_rlabel  symref label (start of function)
TI_abivers  ABI version (str_val).

Definition at line 56 of file tasm-scanner.h.


Constructor & Destructor Documentation

TextAsmScanner::TextAsmScanner const TextAsmScanner  )  [private]
 

Do not use.

TextAsmScanner::TextAsmScanner  ) 
 

Construct text assembly scanner.

TextAsmScanner::~TextAsmScanner  ) 
 

Destroy text assembly scanner and all (allocated and zombie) tokens.


Member Function Documentation

bool TextAsmScanner::_CheckInstAllowed  )  [inline, private]
 

Check if an instruction may be specified now. Returns 0 if not.

Definition at line 211 of file tasm-scanner.h.

References _CheckInstAllowed_Failed(), and insn_storage.

void TextAsmScanner::_CheckInstAllowed_Failed  )  [private]
 

Internally used by _CheckInstAllowed().

Referenced by _CheckInstAllowed().

template<typename T>
const char* TextAsmScanner::_ParseFloat T *  ret,
const char *  str
[private]
 

Overloaded float parsing function.

For internal use only.

Same as _ParseInt() but for floats and without prefix skipping.

template<typename T>
const char* TextAsmScanner::_ParseInt T *  ret,
const char *  str,
char  prefix = '\0'
[private]
 

Overloaded integer parsing function.

For internal use only.

Parse integer by first skipping any number of whitespace before the integer. Additionally, the specified prefix (if not '\0') must be present before the ineger value.

Input string (str) is NUL-terminated.

The parsed integer is stored in *ret.

Returns where the parsed integer string ended (i.e. where to resume parsing).

template<typename T>
const char* TextAsmScanner::_ParseInt0 T *  ret,
const char *  str
[private]
 

Special version which will return 0 if value is not present.

char* TextAsmScanner::_ParseNameStr const char *  str,
const char *  end
[private]
 

Parse name string.

For internal use only.

Parse name string by first skipping any number of whitespace before the name.

If end=NULL, the input string (str) must be NUL-terminated and strlen() is asked for the length.
If end is non-NULL, it points to the end of the string; in this case the string does not have to be NUL-terminated and will be trimmed to size end-str.

Returns:
ALLOC<>ated name string. (Token::~Token() and Token::clear() are responsible for FREEing).

const char* TextAsmScanner::_ParseTypeSpec Token::Type ts,
const char *  str
[private]
 

Parse type spec.

For internal use only.

Parse type spec in the form
type ::= "b" | "s" | "i" | "l" | "f" | "d" |
| "p" [">" TYPEID]
| "a" ( "b" | "s" | "i" | "l" | "f" | "d" | "p" ) .
(FIXME: Do we need "p>TYPEID"??)

Parsed type spec is stored in *ts.

Returns:
Where to go on parsing.

TokenEntry* TextAsmScanner::AllocTokenEntry  )  [inline, private]
 

Important: Override token entry allocation routine.

Definition at line 146 of file tasm-scanner.h.

VM::InstructionStorage* TextAsmScanner::InsnStorage  )  [inline]
 

Used to get insn_storage.

Definition at line 237 of file tasm-scanner.h.

References insn_storage.

int TextAsmScanner::NErrors  )  const [inline]
 

Get the number of lexer errors.

Definition at line 228 of file tasm-scanner.h.

Referenced by VM::AssemblerFile_Plaintext::ParseFile().

void TextAsmScanner::operator= const TextAsmScanner  )  [private]
 

Do not use.

void TextAsmScanner::reset  )  [private]
 

Scanner reset [overriding virtual].

const char* TextAsmScanner::TokID2String TokID  t  )  [static]
 

Return string representation of token ID.

Referenced by VM::AssemblerFile_Plaintext::_AlreadySetError(), and VM::AssemblerFile_Plaintext::_ExpectError().


Friends And Related Function Documentation

int TASM_lex void *   )  [friend]
 


Member Data Documentation

VM::ProgramStorage::Function* TextAsmScanner::insn_storage
 

This InstructionStorage-derived object is used to append all instructions as they come. If NULL, instructions in input will generate an error.

Definition at line 234 of file tasm-scanner.h.

Referenced by _CheckInstAllowed(), VM::AssemblerFile_Plaintext::_ParseProgram_FinishFunction(), VM::AssemblerFile_Plaintext::_ParseProgram_Label(), and InsnStorage().


The documentation for this class was generated from the following file:
Generated on Sat Feb 19 22:35:43 2005 for Ray by doxygen 1.3.5