Table of Contents

Class PCodeSerializer

Namespace
Pl0.Core
Assembly
Pl0.Core.dll

Serializes and parses P-Code in text form.

public static class PCodeSerializer
Inheritance
PCodeSerializer
Inherited Members

Fields

DefaultMaximumInstructionCount

private const int DefaultMaximumInstructionCount = 10000

Field Value

int

MaximumAcceptedInstructionCount

private const int MaximumAcceptedInstructionCount = 100000

Field Value

int

MaximumLineLength

private const int MaximumLineLength = 4096

Field Value

int

MaximumTextLength

private const int MaximumTextLength = 1048576

Field Value

int

Methods

Parse(TextReader, int)

Liest P-Code zeilenweise mit einer festen Befehlsgrenze ein. Parses P-Code line by line with a fixed instruction limit.

public static IReadOnlyList<Instruction> Parse(TextReader reader, int maximumInstructionCount = 10000)

Parameters

reader TextReader

Textquelle. / Text source.

maximumInstructionCount int

Maximale Befehlsanzahl. / Maximum instruction count.

Returns

IReadOnlyList<Instruction>

Die eingelesene Befehlsliste. / The parsed instruction list.

Exceptions

ArgumentOutOfRangeException

Die Grenze liegt außerhalb des unterstützten Bereichs. / The limit is outside the supported range.

FormatException

Der Text ist ungültig oder überschreitet eine Grenze. / The text is invalid or exceeds a limit.

Parse(string)

Liest P-Code-Text als Befehlsfolge ein.

Parses P-Code text into instructions.

public static IReadOnlyList<Instruction> Parse(string text)

Parameters

text string

Der 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

value string

Text to parse.

lineNo int

Line number for error reporting.

partName string

Name 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

value string

Opcode value.

lineNo int

Line number for error reporting.

Returns

Opcode

The parsed opcode.

ReadBoundedLine(TextReader, int, ref int)

private static string? ReadBoundedLine(TextReader reader, int maximumLength, ref int charactersRead)

Parameters

reader TextReader
maximumLength int
charactersRead int

Returns

string

SafeDiagnosticValue(string)

private static string SafeDiagnosticValue(string value)

Parameters

value string

Returns

string

StripComment(string)

Removes // comments from a line.

private static string StripComment(string line)

Parameters

line string

Input 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

instructions IReadOnlyList<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

instructions IReadOnlyList<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

opcode Opcode

Opcode to convert.

Returns

string

Mnemonic string.