ast
Provides interface for parsing Blade code into Abstract Syntax Trees
Properties
- ast.NEWLINE
- newline token
- ast.LPAREN
- left parenthesis (
(
) token
- ast.RPAREN
- right parenthesis (
)
) token
- ast.LBRACKET
- left bracket (
[
) token
- ast.RBRACKET
- right bracket (
]
) token
- ast.LBRACE
- left brace (
{
) token
- ast.RBRACE
- right brace (
}
) token
- ast.SEMICOLON
- semicolon (
;
) token
- ast.COMMA
- comma (
,
) token
- ast.BACKSLASH
- backslash (
\
) token
- ast.BANG
- not (
!
) token
- ast.BANG_EQ
- not equal (
!=
) token
- ast.COLON
- colon (
:
) token
- ast.AT
- at (
@
) token
- ast.DOT
- dot (
.
) token
- ast.RANGE
- range (
..
) token
- ast.TRI_DOT
- tridot (
...
) token
- ast.PLUS
- plus (
+
) token
- ast.PLUS_EQ
- plus equal (
+=
) token
- ast.INCREMENT
- increment (
++
) token
- ast.MINUS
- minus (
-
) token
- ast.MINUS_EQ
- minus equal (
-=
) token
- ast.DECREMENT
- decrement (
--
) token
- ast.MULTIPLY
- multiply (
*
) token
- ast.MULTIPLY_EQ
- multiply equal (
*=
) token
- ast.POW
- pow (
**
) token
- ast.POW_EQ
- pow equal (
**=
) token
- ast.DIVIDE
- divide (
/
) token
- ast.DIVIDE_EQ
- divide equal (
/=
) token
- ast.FLOOR
- floor division (
//
) token
- ast.FLOOR_EQ
- floor divide equal (
//=
) token
- ast.EQUAL
- assignment (
=
) token
- ast.EQUAL_EQ
- equality (
==
) token
- ast.LESS
- less than (
<
) token
- ast.LESS_EQ
- less than or equal (
<=
) token
- ast.LSHIFT
- left shift (
<<
) token
- ast.LSHIFT_EQ
- left shift equal (
<<=
) token
- ast.GREATER
- greater than (
>
) token
- ast.GREATER_EQ
- greather than or equal (
>=
) token
- ast.RSHIFT
- right shift (
>>
) token
- ast.RSHIFT_EQ
- right shift equal (
>>=
) token
- ast.PERCENT
- modulous (
%
) token
- ast.PERCENT_EQ
- modulous equal (
%=
) token
- ast.AMP
- ampersand (
&
) token
- ast.AMP_EQ
- and equal (
&=
) token
- ast.BAR
- bar (
|
) token
- ast.BAR_EQ
- bar equal (
|=
) token
- ast.TILDE
- tilde/not (
~
) token
- ast.TILDE_EQ
- tilde equal (
~=
) token
- ast.XOR
- exclusive or (
^
) token
- ast.XOR_EQ
- exclusive or equal (
^=
) token
- ast.QUESTION
- question (
?
) token
- ast.AND
- and token
- ast.AS
- as token
- ast.ASSERT
- assert token
- ast.BREAK
- break token
- ast.CATCH
- catch token
- ast.CLASS
- class token
- ast.CONTINUE
- continue token
- ast.DEF
- def token
- ast.DEFAULT
- default token
- ast.DIE
- die token
- ast.DO
- do token
- ast.ECHO
- echo token
- ast.ELSE
- else token
- ast.FALSE
- false token
- ast.FINALLY
- finally token
- ast.FOR
- for token
- ast.IF
- if token
- ast.IMPORT
- import token
- ast.IN
- in token
- ast.ITER
- iter token
- ast.NIL
- nil token
- ast.OR
- or token
- ast.PARENT
- parent token
- ast.RETURN
- return token
- ast.SELF
- self token
- ast.STATIC
- static token
- ast.TRUE
- true token
- ast.TRY
- try token
- ast.USING
- using token
- ast.VAR
- var token
- ast.WHEN
- when token
- ast.WHILE
- while token
- ast.LITERAL
- string literal token
- ast.REG_NUMBER
- regular number token
- ast.BIN_NUMBER
- binary number token
- ast.OCT_NUMBER
- octal number token
- ast.HEX_NUMBER
- hexadecimal number token
- ast.IDENTIFIER
- identifier token
- ast.DECORATOR
- decorator token
- ast.INTERPOLATION
- interpolation token
- ast.COMMENT
- comment token
- ast.DOC
- doc block token
- ast.EOF
- eof token
- ast.ERROR
- error token
- ast.EMPTY
- empty token
Functions
- ast.parse(source: string)
- parses a given source code and outputs Blade AST objects. return ParseResult
- ast.json(source: string)
- parses the give source code and outputs a JSON representation of it’s AST structure. return string
Classes
class ParseResult
Represents the result of an ast parse operation @serializable @iterable
class ParseResult methods
- append(item: any)
- adds a new item to the parse result
- length()
- Returns the length of items in the parsed result. returns number
- get(index: int)
- Returns the item at the given ParseResult index or throws exception if out of range. returns Ast
- to_list()
- Returns the items in the ParseResult as a list object. returns List
</span></div>
class Scanner
Blade source code scanner
class Scanner properties
- Scanner.has_error
- reports if an error was encountered in the scaner
class Scanner methods
- Scanner(source: string)
- constructor
- scan()
- scans the source and returns a list of tokens return list[Token]
class Token
Blade source code token @serializable @printable
class Token methods
- Token(type: number, literal: string, line: number)
- constructor
class ParseException < Exception
Exception raised for errors during parsing
class ParseException methods
- ParseException(token: Token, message: string)
- constructor
class Stmt
base Stmt class
class EchoStmt < Stmt
Echo Stmt representation @serializable
class EchoStmt methods
- EchoStmt(value)
- constructor
class ExprStmt < Stmt
Expr Stmt representation @serializable
class ExprStmt methods
- ExprStmt(expr)
- constructor
class IfStmt < Stmt
If Stmt representation @serializable
class IfStmt methods
- IfStmt(condition, truth, falsy)
- constructor
class IterStmt < Stmt
Iter Stmt representation @serializable
class IterStmt methods
- IterStmt(declaration, condition, iterator, body)
- constructor
class WhileStmt < Stmt
While Stmt representation @serializable
class WhileStmt methods
- WhileStmt(condition, body)
- constructor
class DoWhileStmt < Stmt
DoWhile Stmt representation @serializable
class DoWhileStmt methods
- DoWhileStmt(body, condition)
- constructor
class ForStmt < Stmt
For Stmt representation @serializable
class ForStmt methods
- ForStmt(vars, iterable, body)
- constructor
class ContinueStmt < Stmt
Continue Stmt representation @serializable
class BreakStmt < Stmt
Break Stmt representation @serializable
class DieStmt < Stmt
Die Stmt representation @serializable
class DieStmt methods
- DieStmt(exception)
- constructor
class ReturnStmt < Stmt
Return Stmt representation @serializable
class ReturnStmt methods
- ReturnStmt(value)
- constructor
class AssertStmt < Stmt
Assert Stmt representation @serializable
class AssertStmt methods
- AssertStmt(expr, message)
- constructor
class UsingStmt < Stmt
Using Stmt representation @serializable
class UsingStmt methods
- UsingStmt(expr, cases, default_case)
- constructor
class ImportStmt < Stmt
Import Stmt representation @serializable
class ImportStmt methods
- ImportStmt(path, elements)
- constructor
class CatchStmt < Stmt
Catch Stmt representation @serializable
class CatchStmt methods
- CatchStmt(type, var_name, body)
- constructor
class FinallyStmt < Stmt
Finally Stmt representation @serializable
class FinallyStmt methods
- FinallyStmt(body)
- constructor
class TryStmt < Stmt
Try Stmt representation @serializable
class TryStmt methods
- TryStmt(body, catch_stmt, finally_stmt)
- constructor
class CommentStmt < Stmt
Comment Stmt representation @serializable
class CommentStmt methods
- CommentStmt(data)
- constructor
class BlockStmt < Stmt
Block Stmt representation @serializable
class BlockStmt methods
- BlockStmt(body)
- constructor
class AssignStmt < Stmt
Assign Stmt representation @serializable
class AssignStmt methods
- AssignStmt(expr, type, value)
- constructor
class Defn
base Defn class
class DocDefn < Defn
Doc Defn representation @serializable
class DocDefn methods
- DocDefn(data)
- constructor
class Parser
Parses raw Blade tokens and produces an Abstract Syntax Tree
class Parser methods
- Parser(tokens: []Token)
- constructor
- parse()
- parses the raw source tokens passed into relevant class and outputs a stream of AST objects that can be one of Expr (expressions), Stmt (statements) or Decl (declarations) return ParseResult
class Decl
base Decl class
class VarDecl < Decl
Var Decl representation @serializable
class VarDecl methods
- VarDecl(name, value)
- constructor
class FunctionDecl < Decl
Function Decl representation @serializable
class FunctionDecl methods
- FunctionDecl(name, params, body)
- constructor
class MethodDecl < Decl
Method Decl representation @serializable
class MethodDecl methods
- MethodDecl(name, params, body, is_static)
- constructor
class PropertyDecl < Decl
Property Decl representation @serializable
class PropertyDecl methods
- PropertyDecl(name, value, is_static)
- constructor
class ClassDecl < Decl
Class Decl representation @serializable
class ClassDecl methods
- ClassDecl(name, superclass, properties, methods)
- constructor
class Expr
base Expr class
class BinaryExpr < Expr
Binary Expr representation @serializable
class BinaryExpr methods
- BinaryExpr(left, op, right)
- constructor
class GroupExpr < Expr
Group Expr representation @serializable
class GroupExpr methods
- GroupExpr(expression)
- constructor
class LiteralExpr < Expr
Literal Expr representation @serializable
class LiteralExpr methods
- LiteralExpr(value)
- constructor
class IdentifierExpr < Expr
Identifier Expr representation @serializable
class IdentifierExpr methods
- IdentifierExpr(value)
- constructor
class UnaryExpr < Expr
Unary Expr representation @serializable
class UnaryExpr methods
- UnaryExpr(op, right)
- constructor
class ConditionExpr < Expr
Condition Expr representation @serializable
class ConditionExpr methods
- ConditionExpr(expr, truth, falsy)
- constructor
class CallExpr < Expr
Call Expr representation @serializable
class CallExpr methods
- CallExpr(callee, args)
- constructor
class GetExpr < Expr
Get Expr representation @serializable
class GetExpr methods
- GetExpr(expr, name)
- constructor
class SetExpr < Expr
Set Expr representation @serializable
class SetExpr methods
- SetExpr(expr, name, value)
- constructor
class IndexExpr < Expr
Index Expr representation @serializable
class IndexExpr methods
- IndexExpr(args)
- constructor
class ListExpr < Expr
List Expr representation @serializable
class ListExpr methods
- ListExpr(items)
- constructor
class DictExpr < Expr
Dict Expr representation @serializable
class DictExpr methods
- DictExpr(keys, values)
- constructor
class InterpolationExpr < Expr
Interpolation Expr representation @serializable
class InterpolationExpr methods
- InterpolationExpr(data)
- constructor