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

Methods

Parse(string)

Parses P-Code text into instructions.

public static IReadOnlyList<Instruction> Parse(string text)

Parameters

text string

Input text containing p-code.

Returns

IReadOnlyList<Instruction>

Parsed instruction list.

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.

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>)

Converts instructions to mnemonic assembly format.

public static string ToAsm(IReadOnlyList<Instruction> instructions)

Parameters

instructions IReadOnlyList<Instruction>

Instructions to serialize.

Returns

string

Assembly text with one instruction per line.

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.