Class PCodeSerializer
Serializes and parses P-Code in text form.
public static class PCodeSerializer
- Inheritance
-
PCodeSerializer
- Inherited Members
Methods
Parse(string)
Liest P-Code-Text als Befehlsfolge ein.
Parses P-Code text into instructions.
public static IReadOnlyList<Instruction> Parse(string text)
Parameters
textstringDer Eingabetext mit P-Code. / Input text containing P-Code.
Returns
- IReadOnlyList<Instruction>
Die eingelesene Befehlsliste. / The parsed instruction list.
Exceptions
- FormatException
Eine nicht leere Zeile besitzt kein gültiges Opcode-, Ebenen- oder Argumentformat. / A non-empty line has no valid opcode, level, or argument format.
ParseInt(string, int, string)
Parses an integer value or throws a formatted exception.
private static int ParseInt(string value, int lineNo, string partName)
Parameters
valuestringText to parse.
lineNointLine number for error reporting.
partNamestringName of the parsed part.
Returns
- int
Parsed integer.
ParseOpcode(string, int)
Parses an opcode from mnemonic or numeric form.
private static Opcode ParseOpcode(string value, int lineNo)
Parameters
Returns
- Opcode
The parsed opcode.
StripComment(string)
Removes // comments from a line.
private static string StripComment(string line)
Parameters
linestringInput line.
Returns
- string
Line content without comments.
ToAsm(IReadOnlyList<Instruction>)
Wandelt Befehle in das mnemonische Assemblerformat um.
Converts instructions to mnemonic assembly format.
public static string ToAsm(IReadOnlyList<Instruction> instructions)
Parameters
instructionsIReadOnlyList<Instruction>Die zu serialisierenden Befehle. / Instructions to serialize.
Returns
- string
Assemblertext mit einem Befehl pro Zeile. / Assembly text with one instruction per line.
Exceptions
- ArgumentOutOfRangeException
Ein Befehl enthält einen nicht unterstützten Opcode. / An instruction contains an unsupported opcode.
ToCod(IReadOnlyList<Instruction>)
Converts instructions to numeric opcode format.
public static string ToCod(IReadOnlyList<Instruction> instructions)
Parameters
instructionsIReadOnlyList<Instruction>Instructions to serialize.
Returns
- string
Numeric opcode text with one instruction per line.
ToMnemonic(Opcode)
Converts an opcode to its mnemonic form.
private static string ToMnemonic(Opcode opcode)
Parameters
opcodeOpcodeOpcode to convert.
Returns
- string
Mnemonic string.