/* * Reader.h * Author: Hannah C. Tang (hctang@cs) * * Specification of public functions for the Reader struct * (the module parser) * * $Id: Reader.h,v 1.3 2001/12/18 14:48:49 cse466_t Exp $ * */ #ifndef READER_H #define READER_H #include #include "common.h" /* A Reader struct is basically a scanner/parser for the * following simple grammer: * * ::= |
* ::= M { } *
::= P {
} * * ::= | "" * ::= ( ... ) * *
::=
| "" *
::= | * * ::= L {
} * ::= ( ) * ::= an integer * * Comments begin at '#' and end with the line. * */ struct Reader; enum Reader_TokenType { SEQUENCE, /* Program and mode sequences are both returned as SEQUENCE it's up to the user to figure out which is which, depending on previous token type */ MODE_START, MODE_SEQUENCE, PROGRAM_START, PROGRAM_SEQUENCE, LOOP_START, BLOCK_END, END_OF_FILE }; /* Dynamically allocate and free Reader structs */ struct Reader* Reader_malloc( FILE *pInFile ); void Reader_free( struct Reader *pR ); /* Return the type of the next token */ enum Reader_TokenType Reader_getNextTokenType( struct Reader *pR ); /* Get the value of the user-specified mode. Returns Bool_false * if not successful */ Bool Reader_getMode( struct Reader *pR, unsigned int *pNewModeNum ); /* Get the mode-sequence values as a bit-vector. Returns Bool_false * if not successful */ Bool Reader_getModeSequence( struct Reader *pR, unsigned int *pModeSeq ); /* Clear out the Program-start flag. Returns Bool_false if * not successful */ Bool Reader_getProgram( struct Reader *pR ); /* Get the sequence-values. Returns Bool_false if not successful */ Bool Reader_getSequence( struct Reader *pR, unsigned int *pLength, unsigned int *pPeriod, unsigned int *pMode ); /* Get the number of times this loop should execute */ Bool Reader_getLoop( struct Reader *pR, unsigned int *pNumLoops ); /* Clear out the loop-end flag */ Bool Reader_getBlockEnd( struct Reader *pR ); #endif /* READER_H */