# Custom Parsers

A very powerful feature of the Porting Project is the built-in interpreter that is used to support *SalCompileAndEvaluate* and to resolve bind/into expressions in sql statements. The interpreter executes a code tree expressed as a structured collection of code objects. The code tree can be generated in any way. Usually it's generated by a parser that parses the source code language into a code tree.

The built-in parser supports C# syntax only. However it is possible to plug-in a custom parser that is responsible only for the parsing of the source code. A custom parser class needs only to implement the *PPJ.Runtime.Scripting.IScriptParser* interface which defines only one method:

```csharp
public interface IScriptParser
{
 ASTNode Parse(string script);
}
```

The custom parser should only parse the source code text into an Abstract Statement Tree (AST).

To register the custom parser to be used only with SalCompileAndEvaluate use:

```csharp
Sal.Interpreter.Parser = new MyParser();
```

To register the custom parser to be used only with XSalScript, use:

```csharp
XSalScript.Interpreter.Parser = new MyParser();
```

To register the custom parser to be the default parser for everything, including bind/into expressions evaluations, use:

```csharp
PPJ.Runtime.Scriping.ScriptEngine.DefaultParserType = typeof(MyParser);
```

All AST classes are derived from *ASTNode* and are available in the *PPJ.Runtime.Scripting* namespace. There is no public reference manual about the *AST* classes and if you need to write your parser we can provide sample code for your reference and professional support upon request.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.iceteagroup.com/general/framework/extensions/custom-parsers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
