IO Module
This module implements functions for parsing MiniC, Cmd, and Abacus programs and also for printing these programs to streams.
Types
Type | Description |
|
Functions and values
Function or value | Description |
Full Usage:
ParseAbacusProgram ostr sL
Parameters:
TextWriter
sL : string list
Returns: AbcParamsType * AbacusInstr array
|
Function ParseProgram parses an Abacus program from the list of strings sL that are the lines of an Abacus file. If a syntax error occurs, error messages are written to ostr. The result is an Abacus program, i.e., an array of Abacus instructions where branch and jump instructions refer to indices of this array. For the syntax of the expected Abacus program, see the comments of function ParseProgramFromFile.
|
Full Usage:
ParseAbacusProgramFromFile ostr filename
Parameters:
TextWriter
filename : string
Returns: AbcParamsType * AbacusInstr array
|
Function ParseAbacusProgramFromFile parses an Abacus program from the contents of the file with the given filename, and writes error messages to the output TextWriter ostr. In addition to the Abacus instructions, the file may also contain in a header before the values of the parameters of the Abacus computer. In total, the following syntax is assumed:
|
Full Usage:
ParseDeclFromStream stream
Parameters:
TextReader
Returns: (string * TypeC) list
|
|
|
|
Full Usage:
ParseExprFromStream decls stream
Parameters:
(string * TypeC) array
stream : TextReader
Returns: ExprC
|
parsing a MiniC expression from a stream where types are determined according to the given declaration of variables
|
|
|
Full Usage:
ParseMiniCFromFile optOstr filename
Parameters:
'a option
filename : string
Returns: MiniCProgram
|
parsing a program from a file (errors are written to output stream optOstr, if that is not None).
|
Full Usage:
ParseMiniCFromStream optOstr instr
Parameters:
'a option
instr : TextReader
Returns: MiniCProgram
|
ParseMiniCFromStream parses a MiniC program from a given input stream instr (errors are written to output stream optOstr, if that is not None).
|
Full Usage:
ParseMiniCFromString optOstr s
Parameters:
'a option
s : string
Returns: MiniCProgram
|
ParseMiniCFromString parses a MiniC program from a given string s (errors are written to output stream optOstr, if that is not None).
|
|
parsing a MiniC expression from a stream where Cnat is used for all numeric types
|
|
parsing a MiniC expression from a string where Cnat is used for all numeric types
|
Full Usage:
PrintAbacusProgram indent ostr abcp cmt
Parameters:
string
ostr : TextWriter
abcp : Map<int, AbacusInstr>
cmt : Map<int, string>
|
PrintAbacusProgram prints an Abacus program p to output stream ostr with an indentation string indent and additional comments cmt.
|
|
PrintCmdProg prints a CmdType program to TextWriter ostr.
|
Full Usage:
ReadLines filename
Parameters:
string
Returns: string list
|
|
|
|