Skip to content

RSML.Parser.RSParser Class

The default parser for Red Sea Markup Language.

Hierarchy

flowchart TB
    RSParser --> System.Object

Constructors

RSParser contains 4 constructor methods.

RSParser(System.String rsmlContents)

Create a new parser instance from a RSML System.String.

Parameters

System.String rsmlContents

The RSML data to load, in the form of a System.String.

RSParser(StringReader rsmlReader)

Create a new parser instance from a StringReader containing RSML.

Parameters

StringReader rsmlReader

The reader containing RSML.

RSParser(RSParser parser)

Creates a new parser from another one's data.

Parameters

RSParser parser

An instance of a Red Sea Markup Language parser.

RSParser(RSDocument document)

Creates a new parser from a document, but does not make changes to the document or to the document's linked parser.

Parameters

RSDocument document

The document whose RSML to load.


Instance Methods

RSParser contains 8 instance methods.

DefineOperator(OperatorType operatorType, System.String newOperator)

Defines an operator to match a specified System.String.

Parameters

OperatorType operatorType

The operator whose token to override.

System.String newOperator

The new token to give the operator.

EvaluateRSML(System.String? linesepChar = null)

Parses and evaluates the document.

Parameters

System.String? linesepChar = null

The custom line separation character to use, instead of System.Environment.NewLine. Defaults to null. If null, falls back to System.Environment.NewLine.

Returns

System.String

The System.String matching the return value of the only match that had a primary operator.

null

There were no primary matches.

EvaluateRSML(bool expandAny, System.String? linesepChar = null)

Parses and evaluates the document.

Parameters

bool expandAny

If set to true, expands any into Regex expression .+, indicating that any RID will be a match.

System.String? linesepChar = null

The custom line separation character to use, instead of System.Environment.NewLine. Defaults to null. If null, falls back to System.Environment.NewLine.

Returns

System.String

The System.String matching the return value of the only match that had a primary operator.

null

There were no primary matches.

EvaluateRSMLWithCustomRid(System.String customRid, System.String? linesepChar = null)

Parses and evaluates the document.

Parameters

System.String customRid

A custom RID to pass to the parser, instead of the host's RID.

System.String? linesepChar = null

The custom line separation character to use, instead of System.Environment.NewLine. Defaults to null. If null, falls back to System.Environment.NewLine.

Returns

System.String

The System.String matching the return value of the only match that had a primary operator.

null

There were no primary matches.

EvaluateRSMLWithCustomRid(System.String customRid, bool expandAny, System.String? linesepChar = null)

Parses and evaluates the document.

Parameters

System.String customRid

A custom RID to pass to the parser, instead of the host's RID.

bool expandAny

If set to true, expands any into Regex expression .+, indicating that any RID will be a match.

System.String? linesepChar = null

The custom line separation character to use, instead of System.Environment.NewLine. Defaults to null. If null, falls back to System.Environment.NewLine.

Returns

System.String

The System.String matching the return value of the only match that had a primary operator.

null

There were no primary matches.

RegisterAction(OperatorType operatorType, Action<RSParser, System.String> action)

Register a main action. Can either be secondary or tertiary.

Parameters

OperatorType operatorType

The operator whose action to redefine.

Action<RSParser, System.String> action

The action to override the old one. In this action, RSParser stands for self (the parser evaluating the RSML content), which means the parser can be changed during evaluation-time. The System.String stands for the value passed to the operator, as in win.+ -> "value".

Exceptions

ImmutableActionException

Attempted to redefine the primary operator's behavior.

RegisterSpecialFunction(System.String nameOfSpecial, Func<RSParser, System.String, byte> specialAction)

Register a new special action.

Parameters

System.String nameOfSpecial

The name of the special action (without the @).

Func<RSParser, System.String, byte> action

The special action to add. In this action, RSParser stands for self (the parser evaluating the RSML content), which means the parser can be changed during evaluation-time. The System.String stands for the argument passed to the action, as in @MyAction Argument. The byte is the return value of the function, as seen below.

Return Value (byte) Special Effect on Evaluation
0 None.
1 to 249 None.
250 Ends evaluation with no matches found (null).
251 Removes all registered special actions, apart from @EndAll.
252 Redefines the operators to match official-25's ones.
253 to 255 None.

ToString()

Note

ToString() overwrites parent class' System.Object.ToString().

Returns the parser's contents.

Returns

System.String : The loaded RSML.