Class PythonParser
Represents a class that performs syntax and lexical analysis of specified Python code text.
[ToolboxBitmap(typeof(PythonParser), "Images.PythonParser.Icon.bmp")]
public class PythonParser : LspParser, IComponent, IDisposable, ISyntaxParser, IParser, ILexer, INotify, IUpdate, IImport, ILspDocumentProvider
- Inheritance
-
PythonParser
- Implements
- Derived
Examples
Here is how to declare a PythonParser and assign it to the edit control from the C# code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
var parser = new Alternet.Syntax.Parsers.Lsp.Python.PythonParser();
var edit = new Alternet.Editor.SyntaxEdit();
edit.Parent = this;
edit.Lexer = parser;
string fileName = "myfile.py";
if (System.IO.File.Exists(fileName))
{
parser.FileName = fileName;
edit.LoadFile(fileName);
}
}
}
Here is how to declare a PythonParser and assign it to the edit control from the Visual Basic code:
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim parser = New Alternet.Syntax.Parsers.Lsp.Python.PythonParser()
Dim edit = New Alternet.Editor.SyntaxEdit()
edit.Parent = Me
edit.Lexer = parser
Dim fileName As String = "myfile.py"
If System.IO.File.Exists(fileName) Then
parser.FileName = fileName
edit.LoadFile(fileName)
End If
End Sub
End Class
Remarks
PythonParser is a non-visual component designed to perform syntax highlighting for Python language.� This LangServer-based parser relies on the Python Language server to provide features like full syntax and analysis of the Python code. When linked to the SyntaxEdit or TextEditor controls, this parser drives additional features such as code completion, code outlining, and underlying syntax errors and warnings.
Here are some of the essential features provided by the PythonParser:
- Syntax Highlighting
- IntelliSense (Code completion)
- Code Outlining
Constructors
- PythonParser()
Initializes a new instance of the PythonParser class with default settings.
- PythonParser(IContainer)
Initializes a new instance of the PythonParser class with specified container.
Fields
- DefaultPythonSyntaxOptions
Represents default set of flags determining syntax parsing and formatting behavior.
Properties
- CaseSensitive
Gets or sets a boolean value that indicates whether
SyntaxParser
should perform case-sensitive analysis of its content.
- CodeStyleWarningsEnabled
Gets or sets a boolean value which indicates is code style warnings are enabled.
Methods
- CreateRepository()
Creates
ICodeCompletionRepository
to perform code completion functionality for this parser.
- ResetOptions()
Resets
Options
to the default value.
- ShouldSerializeOptions()
Indicates whether the
Options
property should be persisted.