python_grammar

package
v0.19.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LexerWithSOF added in v0.17.4

func LexerWithSOF(parent lexer.Definition) lexer.Definition

func Parse

func Parse(filePath string) (*language.FileInfo, error)

Types

type Class

type Class struct {
	Name string `(NewLine | SOF) "class" Space @Ident`
}

type File

type File struct {
	Statements []*Statement `(@@ | SOF | ANY | ALL | Ident | Space | NewLine | String | MultilineString)*`
}

type FromImport

type FromImport struct {
	Indented bool           `@Space?`
	Relative []bool         `"from" (Space | @".") @"."*`
	Path     []string       `@Ident? (Space? "." Space? @Ident)* Space`
	All      bool           `"import" Space ( @ALL |`
	Names    []ImportedName `` /* 153-byte string literal not displayed */
}

type Function

type Function struct {
	Name string `(NewLine | SOF) ("async" Space)? "def" Space @Ident`
}

type Import

type Import struct {
	Indented bool     `@Space?`
	Path     []string `"import" Space @Ident (Space? "." Space? @Ident)*`
	Alias    string   `(Space "as" Space @Ident)?`
}

type ImportedName

type ImportedName struct {
	Name  string `@Ident`
	Alias string `(Space "as" Space @Ident)?`
}

type Statement

type Statement struct {
	// imports.
	FromImport *FromImport `@@ |`
	Import     *Import     `@@ |`
	// exports.
	Class          *Class          `@@ |`
	Function       *Function       `@@ |`
	VariableTyping *VariableTyping `@@ |`
	VariableUnpack *VariableUnpack `@@ |`
	VariableAssign *VariableAssign `@@`
}

type VariableAssign

type VariableAssign struct {
	Names []string `(NewLine | SOF) (@Ident Space? "=" Space?)+`
}

type VariableTyping

type VariableTyping struct {
	Name string `(NewLine | SOF) @Ident Space? ":" Space? Ident`
}

type VariableUnpack

type VariableUnpack struct {
	Names []string `` /* 172-byte string literal not displayed */
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL