YREA-SLS/SLS_Python/sls_py.pyi

143 lines
3.0 KiB
Python

from dataclasses import dataclass, field
from enum import Enum, auto
from typing import Callable, Dict, List, Optional
def main() -> int:
...
SLS_NAME: str
SLS_VERSION: str
SLS_COMMIT: str
INTERPRETER_NAME: str
INTERPRETER_VER: int
MODULE_TIMESTAMP: str
SLS_INFO_STRING_1: str
SLS_INFO_STRING_2: str
class LexerInfo:
filename: str
source_code: str
pos: int
column: int
line: int
def __init__(self, filename: str = "", source_code: str = ""): ...
class TokenType(Enum):
EOF = auto()
IDENTIFIER = auto()
INTEGER = auto()
FLOAT = auto()
DOUBLE = auto()
CHARACTER = auto()
STRING = auto()
BOOLEAN = auto()
ARRAY = auto()
TOKEN_STRING = auto()
TYPE_TUPLE = auto()
@dataclass
class Identifier:
name: str
is_literal: bool
class IntegerBuiltInType(Enum):
I64 = auto()
I32 = auto()
I16 = auto()
I8 = auto()
U64 = auto()
U32 = auto()
U16 = auto()
U8 = auto()
@dataclass
class IntegerLiteral:
value: int
type: IntegerBuiltInType
@dataclass
class TokenString:
tokens: List["Token"] = field(default_factory=list)
def deep_copy(self) -> TokenString: ...
@dataclass
class Token:
type: TokenType
identifier: Optional[Identifier] = None
integer_literal: Optional[IntegerLiteral] = None
float_literal: Optional[float] = None
double_literal: Optional[float] = None
character_literal: Optional[int] = None
string_literal: Optional[str] = None
boolean_literal: Optional[bool] = None
token_string: Optional[TokenString] = None
def lexical_analysis(lexer_info: LexerInfo) -> List[Token]:
...
class StackType(Enum):
IDENTIFIER = auto()
I64 = auto()
I32 = auto()
I16 = auto()
I8 = auto()
U64 = auto()
U32 = auto()
U16 = auto()
U8 = auto()
FLOAT = auto()
DOUBLE = auto()
CHARACTER = auto()
BOOLEAN = auto()
TOKEN_STRING = auto()
CALLABLE = auto()
@dataclass
class StackEntry:
type: StackType
value: object
class FunctionType(Enum):
TOKEN_STRING = auto()
BUILTIN = auto()
@dataclass
class FunctionItem:
type: FunctionType
token_string: Optional[TokenString] = None
builtin: Optional[Callable[["InterpreterState"], bool]] = None
@classmethod
def from_token_string(cls, ts: TokenString) -> "FunctionItem": ...
@classmethod
def from_builtin(cls, fn: Callable[["InterpreterState"], bool]) -> "FunctionItem": ...
class InterpreterState:
stack: List[StackEntry]
functions: Dict[str, FunctionItem]
def __init__(self): ...
def push(self, entry: StackEntry) -> None: ...
def pop(self) -> Optional[StackEntry]: ...
def top(self) -> Optional[StackEntry]: ...
def add_function(self, name: str, item: FunctionItem) -> None: ...
def get_function(self, name: str) -> Optional[FunctionItem]: ...
def push_token(self, token: Token) -> bool: ...
def execute_func(self, key: str) -> bool: ...
def execute_token_string(self, token_string: TokenString) -> bool: ...
def execute(self, token: Token) -> bool: ...