├── .gitignore ├── README.md ├── _.PNG ├── _tbnf ├── FableSedlex │ ├── __init__.py │ ├── code_gen.py │ ├── code_gen_python.py │ └── sedlex.py ├── fable_modules │ ├── __init__.py │ ├── cache_info.json │ ├── fable_library │ │ ├── __init__.py │ │ ├── array.py │ │ ├── async_.py │ │ ├── async_builder.py │ │ ├── big_int.py │ │ ├── bit_converter.py │ │ ├── boolean.py │ │ ├── char.py │ │ ├── choice.py │ │ ├── date.py │ │ ├── date_offset.py │ │ ├── decimal.py │ │ ├── double.py │ │ ├── fsharp_collections.py │ │ ├── fsharp_core.py │ │ ├── global_.py │ │ ├── guid.py │ │ ├── int32.py │ │ ├── list.py │ │ ├── long.py │ │ ├── mailbox_processor.py │ │ ├── map.py │ │ ├── map_util.py │ │ ├── mutable_map.py │ │ ├── mutable_set.py │ │ ├── native.py │ │ ├── numeric.py │ │ ├── option.py │ │ ├── range.py │ │ ├── reflection.py │ │ ├── reg_exp.py │ │ ├── seq.py │ │ ├── seq2.py │ │ ├── set.py │ │ ├── string.py │ │ ├── system_collections_generic.py │ │ ├── system_text.py │ │ ├── task.py │ │ ├── task_builder.py │ │ ├── time_span.py │ │ ├── timer.py │ │ ├── types.py │ │ ├── uri.py │ │ └── util.py │ └── fable_python │ │ ├── Fable.Python.fsproj │ │ ├── cognite-sdk │ │ ├── CogniteSdk.fs │ │ ├── __init__.py │ │ └── cognite_sdk.py │ │ ├── flask │ │ ├── Flask.fs │ │ ├── __init__.py │ │ └── flask.py │ │ ├── jupyter │ │ ├── IPyWidgets.fs │ │ ├── IPython.fs │ │ ├── __init__.py │ │ ├── ipy_widgets.py │ │ └── ipython.py │ │ ├── microbit │ │ ├── MicroBit.fs │ │ ├── Speach.fs │ │ ├── __init__.py │ │ ├── micro_bit.py │ │ └── speach.py │ │ ├── pyproject.toml │ │ └── stdlib │ │ ├── Ast.fs │ │ ├── Base64.fs │ │ ├── Builtins.fs │ │ ├── Html.fs │ │ ├── Json.fs │ │ ├── Math.fs │ │ ├── Os.fs │ │ ├── Queue.fs │ │ ├── Sys.fs │ │ ├── Time.fs │ │ ├── TkInter.fs │ │ ├── __init__.py │ │ ├── ast.py │ │ ├── base64.py │ │ ├── builtins.py │ │ ├── html.py │ │ ├── json.py │ │ ├── math.py │ │ ├── os.py │ │ ├── queue.py │ │ ├── sys.py │ │ ├── time.py │ │ └── tk_inter.py └── src │ ├── __init__.py │ ├── analysis.py │ ├── apis.py │ ├── backends_common.py │ ├── backends_csharp_antlr.py │ ├── backends_ocaml_menhir.py │ ├── backends_python_lark.py │ ├── exceptions.py │ ├── grammar.py │ ├── macro_resolve.py │ ├── main.py │ ├── op.py │ ├── resource_keys.py │ ├── unification.py │ └── utils.py ├── backend_pygments ├── __init__.py ├── lua_sh.lark ├── lua_sh_construct.py ├── lua_sh_lexer.py ├── lua_sh_parser.py └── lua_sh_require.py ├── backend_vscode ├── .vscodeignore ├── language-configuration.json ├── out │ ├── extension.js │ ├── extension.js.map │ ├── lua_shLexer.js │ ├── lua_shLexer.js.map │ ├── lua_shListener.js │ ├── lua_shListener.js.map │ ├── lua_shParser.js │ ├── lua_shParser.js.map │ ├── lua_sh_provider.js │ ├── lua_sh_provider.js.map │ ├── lua_sh_require.js │ └── lua_sh_require.js.map ├── package-lock.json ├── package.json ├── src │ ├── extension.ts │ ├── lua_sh.g4 │ ├── lua_shLexer.ts │ ├── lua_shListener.ts │ ├── lua_shParser.ts │ ├── lua_sh_provider.ts │ ├── lua_sh_require.ts │ └── rename.tbnf.py ├── testit.rua └── tsconfig.json ├── base16_applepips.py ├── build.ps1 ├── lua.tbnf ├── run.py ├── testit.rua └── vscode_sh_template ├── .vscodeignore ├── SH.tbnf ├── language-configuration.json ├── out ├── SHLexer.js ├── SHLexer.js.map ├── SHListener.js ├── SHListener.js.map ├── SHParser.js ├── SHParser.js.map ├── SH_require.js ├── SH_require.js.map ├── SHprovider.js ├── SHprovider.js.map ├── SHrequire.js ├── SHrequire.js.map ├── extension.js ├── extension.js.map ├── lua_shLexer.js ├── lua_shLexer.js.map ├── lua_shListener.js ├── lua_shListener.js.map ├── lua_shParser.js ├── lua_shParser.js.map ├── lua_sh_provider.js ├── lua_sh_provider.js.map ├── lua_sh_require.js └── lua_sh_require.js.map ├── package-lock.json ├── package.json ├── src ├── SH.g4 ├── SHLexer.ts ├── SHListener.ts ├── SHParser.ts ├── SH_require.ts ├── SHprovider.ts ├── extension.ts └── rename.tbnf.py ├── testit.comf └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | /cross-editor-highlighter/ 2 | .antlr/ 3 | /parser-data/ 4 | *.interp 5 | *.tokens 6 | /**.g4 7 | __pycache__ 8 | /runtests/ocaml_simple_json/_build/ 9 | /FableSedlex/ 10 | bin/ 11 | obj/ 12 | .ionide/ 13 | .idea/ 14 | .fake 15 | .config/ 16 | coveragereport/ 17 | dexe_smlfs/publish/ 18 | 19 | *.egg-info/ 20 | build/ 21 | dist/ 22 | examples/out-*/ 23 | sphinx-docs/ 24 | 25 | **.mlfso 26 | **.mlfsa 27 | **.mlfsf 28 | .vscode/ 29 | obj/ 30 | 31 | 32 | *.annot 33 | *.cmo 34 | *.cma 35 | *.cmi 36 | *.a 37 | *.o 38 | *.cmx 39 | *.cmxs 40 | *.cmxa 41 | 42 | # ocamlbuild working directory 43 | _build/ 44 | 45 | # ocamlbuild targets 46 | *.byte 47 | *.native 48 | 49 | # oasis generated files 50 | setup.data 51 | setup.log 52 | 53 | # Merlin configuring file for Vim and Emacs 54 | .merlin 55 | 56 | # Dune generated files 57 | *.install 58 | 59 | # Local OPAM switch 60 | _opam/ 61 | 62 | lib-cov 63 | *.seed 64 | *.log 65 | *.csv 66 | *.dat 67 | *.out 68 | *.pid 69 | *.gz 70 | *.swp 71 | 72 | pids 73 | logs 74 | results 75 | tmp 76 | 77 | # Build 78 | public/css/main.css 79 | 80 | # Coverage reports 81 | coverage 82 | 83 | # API keys and secrets 84 | .env 85 | 86 | # Dependency directory 87 | node_modules 88 | bower_components 89 | 90 | # Editors 91 | .idea 92 | *.iml 93 | 94 | # OS metadata 95 | .DS_Store 96 | Thumbs.db 97 | 98 | # Ignore built ts files 99 | dist/**/* 100 | 101 | # ignore yarn.lock 102 | yarn.lock -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Cross-editor contextual syntax highlighter via Typed BNF 2 | 3 | ![lua](_.PNG) 4 | 5 | 6 | One grammar, syntax highlighters everywhere. 7 | 8 | PS: **NOTE that parentheses in function arguments and parameters have different colors.** 9 | 10 | PPS: **The amount of code required to implement such a cross-editor SH(~100 lines), is many orders of magnitude smaller than for the tmLanguage system(~10000 lines and unreadable)**. 11 | 12 | ### build grammar for VScode 13 | 14 | build: `tbnf .\cross-editor-highlighter\lua.tbnf .\cross-editor-highlighter\backend_vscode\src "lua_sh" --backend typescript-antlr` 15 | 16 | 17 | ### build grammar for pygments 18 | 19 | build: ` tbnf .\cross-editor-highlighter\lua.tbnf .\cross-editor-highlighter\backend_pygments\ "lua_sh" --backend python-lark` 20 | -------------------------------------------------------------------------------- /_.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thautwarm/cross-editor-syntax-highlighter/7be87440d6b011397f1372e6c5cd0e8e21150658/_.PNG -------------------------------------------------------------------------------- /_tbnf/FableSedlex/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/async_.py: -------------------------------------------------------------------------------- 1 | from threading import Timer 2 | from typing import Any, Callable, List, Optional, TypeVar, Union 3 | 4 | from .async_builder import ( 5 | CancellationToken, 6 | IAsync, 7 | IAsyncContext, 8 | OperationCanceledError, 9 | Trampoline, 10 | empty_continuation, 11 | protected_bind, 12 | protected_cont, 13 | protected_return, 14 | ) 15 | from .choice import Choice_makeChoice1Of2, Choice_makeChoice2Of2 # type: ignore 16 | 17 | T = TypeVar("T") 18 | 19 | 20 | default_cancellation_token = CancellationToken() 21 | 22 | 23 | def create_cancellation_token(arg: Union[int, bool, None] = None) -> CancellationToken: 24 | cancelled = arg if isinstance(arg, bool) else False 25 | token = CancellationToken(cancelled) 26 | if isinstance(arg, int): 27 | timer = Timer(arg / 1000.0, token.cancel) # type: ignore 28 | timer.start() 29 | 30 | return token 31 | 32 | 33 | def cancel(token: CancellationToken) -> None: 34 | token.cancel() 35 | 36 | 37 | def cancel_after(token: CancellationToken, ms: int) -> None: 38 | timer = Timer(ms / 1000.0, token.cancel) 39 | timer.start() 40 | 41 | 42 | def sleep(millisecondsDueTime: int) -> IAsync[T]: 43 | def cont(ctx: IAsyncContext[T]): 44 | def cancel(): 45 | timer.cancel() 46 | ctx.on_cancel(OperationCanceledError()) 47 | 48 | token_id = ctx.cancel_token.add_listener(cancel) 49 | 50 | def timeout(): 51 | ctx.cancel_token.remove_listener(token_id) 52 | ctx.on_success() 53 | 54 | timer = Timer(millisecondsDueTime / 1000.0, timeout) 55 | timer.start() 56 | 57 | return protected_cont(cont) 58 | 59 | 60 | def ignore(computation: IAsync[T]) -> IAsync[None]: 61 | return protected_bind(computation, lambda _x=None: protected_return()) 62 | 63 | 64 | def catch_async(work: IAsync[T]) -> IAsync[T]: 65 | def cont(ctx: IAsyncContext[T]): 66 | def on_success(x: Optional[T] = None): 67 | ctx.on_success(Choice_makeChoice1Of2(x)) 68 | 69 | def on_error(err: Exception): 70 | ctx.on_success(Choice_makeChoice2Of2(err)) 71 | 72 | ctx_ = IAsyncContext.create(on_success, on_error, ctx.on_cancel, ctx.trampoline, ctx.cancel_token) 73 | work(ctx_) 74 | 75 | return protected_cont(cont) 76 | 77 | 78 | def from_continuations(f: Callable[[List[Callable[[Any], None]]], None]) -> Callable[[IAsyncContext[Any]], None]: 79 | def cont(ctx: IAsyncContext[Any]): 80 | f([ctx.on_success, ctx.on_error, ctx.on_cancel]) 81 | 82 | return protected_cont(cont) 83 | 84 | 85 | def start_with_continuations( 86 | computation, continuation=None, exception_continuation=None, cancellation_continuation=None, cancellation_token=None 87 | ) -> Callable[[IAsyncContext], None]: 88 | trampoline = Trampoline() 89 | 90 | ctx = IAsyncContext.create( 91 | continuation or empty_continuation, 92 | exception_continuation or empty_continuation, 93 | cancellation_continuation or empty_continuation, 94 | trampoline, 95 | cancellation_token or default_cancellation_token, 96 | ) 97 | 98 | return computation(ctx) 99 | 100 | 101 | def start(computation, cancellation_token=None) -> Callable[[IAsyncContext], None]: 102 | return start_with_continuations(computation, cancellation_token=cancellation_token) 103 | 104 | 105 | def start_immediate(computation, cancellation_token=None) -> Callable[[IAsyncContext], None]: 106 | return start(computation, cancellation_token) 107 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/big_int.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | from typing import Any 3 | 4 | from .types import FSharpRef 5 | 6 | 7 | def from_zero() -> int: 8 | return 0 9 | 10 | 11 | def from_one() -> int: 12 | return 1 13 | 14 | 15 | def from_int32(x: int) -> int: 16 | return x 17 | 18 | 19 | def from_int64(x: int) -> int: 20 | return x 21 | 22 | 23 | def from_string(x: str) -> int: 24 | return int(x) 25 | 26 | 27 | def op_addition(a: int, b: int) -> int: 28 | return a + b 29 | 30 | 31 | def parse(value: Any) -> int: 32 | return int(value) 33 | 34 | 35 | def to_string(value: int) -> str: 36 | return str(value) 37 | 38 | 39 | def to_byte(value: int) -> int: 40 | return value 41 | 42 | 43 | def to_sbyte(value: int) -> int: 44 | return value 45 | 46 | 47 | def to_int16(value: int) -> int: 48 | return value 49 | 50 | 51 | def to_uint16(value: int) -> int: 52 | return value 53 | 54 | 55 | def to_int32(value: int) -> int: 56 | return value 57 | 58 | 59 | def to_uint32(value: int) -> int: 60 | return value 61 | 62 | 63 | def to_int64(value: int) -> int: 64 | return value 65 | 66 | 67 | def to_uint64(value: int) -> int: 68 | return value 69 | 70 | 71 | def to_single(value: int) -> float: 72 | return float(value) 73 | 74 | 75 | def to_double(value: int) -> float: 76 | return float(value) 77 | 78 | 79 | def to_decimal(value: int) -> Decimal: 80 | return Decimal(value) 81 | 82 | 83 | def equals(a: int, b: int) -> bool: 84 | return a == b 85 | 86 | 87 | def try_parse(string: str, defValue: FSharpRef[int]) -> bool: 88 | try: 89 | defValue.contents = parse(string) 90 | return True 91 | except Exception: 92 | return False 93 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/bit_converter.py: -------------------------------------------------------------------------------- 1 | import struct 2 | import sys 3 | 4 | from typing import Optional 5 | 6 | 7 | def get_bytes_char(value: str) -> bytes: 8 | return bytearray(bytes(value, "UTF-8")) 9 | 10 | 11 | def get_bytes_int16(value: int) -> bytes: 12 | return bytearray(value.to_bytes(length=2, byteorder=sys.byteorder)) 13 | 14 | 15 | def get_bytes_uint16(value: int) -> bytes: 16 | return bytearray(value.to_bytes(length=2, byteorder=sys.byteorder)) 17 | 18 | 19 | def get_bytes_int32(value: int) -> bytes: 20 | return bytearray(value.to_bytes(length=4, byteorder=sys.byteorder)) 21 | 22 | 23 | def get_bytes_uint32(value: int) -> bytes: 24 | return bytearray(value.to_bytes(length=4, byteorder=sys.byteorder)) 25 | 26 | 27 | def get_bytes_int64(value: int) -> bytes: 28 | return bytearray(value.to_bytes(length=8, byteorder=sys.byteorder)) 29 | 30 | 31 | def get_bytes_uint64(value: int) -> bytes: 32 | return bytearray(value.to_bytes(length=8, byteorder=sys.byteorder)) 33 | 34 | 35 | def get_bytes_boolean(value: bool) -> bytes: 36 | return bytearray(value.to_bytes(length=1, byteorder=sys.byteorder)) 37 | 38 | 39 | def get_bytes_single(value: float) -> bytes: 40 | return bytearray(struct.pack("f", value)) 41 | 42 | 43 | def get_bytes_double(value: float) -> bytes: 44 | return bytearray(struct.pack("d", value)) 45 | 46 | 47 | def int64bits_to_double(value: int) -> float: 48 | bytes = value.to_bytes(length=8, byteorder=sys.byteorder) 49 | [number] = struct.unpack("d", bytes) 50 | return number 51 | 52 | 53 | def double_to_int64bits(value: float) -> int: 54 | bytes = bytearray(struct.pack("d", value)) 55 | [number] = struct.unpack("q", bytes) 56 | return number 57 | 58 | 59 | def to_boolean(bytes: bytearray, offset: int) -> bool: 60 | return bool(bool.from_bytes(bytes[offset : offset + 1], byteorder=sys.byteorder)) 61 | 62 | 63 | def to_char(bytes: bytearray, offset: int) -> str: 64 | return bytes[offset : offset + 1].decode("utf8") 65 | 66 | 67 | def to_int16(bytes: bytearray, offset: int) -> int: 68 | return int.from_bytes(bytes[offset : offset + 2], byteorder=sys.byteorder, signed=True) 69 | 70 | 71 | def to_uint16(bytes: bytearray, offset: int) -> int: 72 | return int.from_bytes(bytes[offset : offset + 2], byteorder=sys.byteorder, signed=False) 73 | 74 | 75 | def to_int32(bytes: bytearray, offset: int) -> int: 76 | return int.from_bytes(bytes[offset : offset + 4], byteorder=sys.byteorder, signed=True) 77 | 78 | 79 | def to_uint32(bytes: bytearray, offset: int) -> int: 80 | return int.from_bytes(bytes[offset : offset + 4], byteorder=sys.byteorder, signed=False) 81 | 82 | 83 | def to_int64(bytes: bytes, offset: int) -> int: 84 | return int.from_bytes(bytes[offset : offset + 8], byteorder=sys.byteorder, signed=True) 85 | 86 | 87 | def to_uint64(bytes: bytearray, offset: int) -> int: 88 | return int.from_bytes(bytes[offset : offset + 8], byteorder=sys.byteorder, signed=False) 89 | 90 | 91 | def to_single(bytes: bytearray, offset: int) -> float: 92 | [number] = struct.unpack("f", bytes[offset : offset + 4]) 93 | return number 94 | 95 | 96 | def to_double(bytes: bytearray, offset: int) -> float: 97 | [number] = struct.unpack("d", bytes[offset : offset + 8]) 98 | return number 99 | 100 | 101 | def to_string(bytes: bytearray, offset: int = 0, count: Optional[int] = None) -> str: 102 | count = len(bytes) if count is None else count 103 | return "-".join([f"{x:02x}" for x in bytes[offset : offset + count]]) 104 | 105 | 106 | def is_little_endian() -> bool: 107 | return sys.byteorder == "little" 108 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/boolean.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | from .types import FSharpRef 4 | 5 | 6 | def try_parse(string: str, defValue: FSharpRef[bool]) -> bool: 7 | string = string.strip().capitalize() 8 | if string == "True": 9 | defValue.contents = True 10 | return True 11 | elif string == "False": 12 | defValue.contents = False 13 | return True 14 | 15 | return False 16 | 17 | 18 | def parse(value: Any) -> bool: 19 | def_value: FSharpRef[bool] = FSharpRef(False) 20 | if try_parse(value, def_value): 21 | return def_value.contents 22 | 23 | raise ValueError(f"String '{value}' was not recognized as a valid Boolean.") 24 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/char.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class UnicodeCategory(Enum): 5 | UppercaseLetter = 0 6 | LowercaseLetter = 1 7 | TitlecaseLetter = 2 8 | ModifierLetter = 3 9 | OtherLetter = 4 10 | NonSpacingMark = 5 11 | SpacingCombiningMark = 6 12 | EnclosingMark = 7 13 | DecimalDigitNumber = 8 14 | LetterNumber = 9 15 | OtherNumber = 10 16 | SpaceSeparator = 11 17 | LineSeparator = 12 18 | ParagraphSeparator = 13 19 | Control = 14 20 | Format = 15 21 | Surrogate = 16 22 | PrivateUse = 17 23 | ConnectorPunctuation = 18 24 | DashPunctuation = 19 25 | OpenPunctuation = 20 26 | ClosePunctuation = 21 27 | InitialQuotePunctuation = 22 28 | FinalQuotePunctuation = 23 29 | OtherPunctuation = 24 30 | MathSymbol = 25 31 | CurrencySymbol = 26 32 | ModifierSymbol = 27 33 | OtherSymbol = 28 34 | OtherNotAssigned = 29 35 | 36 | 37 | def unicodeCategoryFunc(cp): 38 | raise NotImplementedError 39 | 40 | 41 | def char_code_at(s: str, index: int): 42 | if index >= 0 and index < len(s): 43 | return ord(s[index]) 44 | else: 45 | raise ValueError("Index out of range.") 46 | 47 | 48 | def getUnicodeCategory2(s: str, index: int): 49 | cp = char_code_at(s, index) 50 | return unicodeCategoryFunc(cp) 51 | 52 | 53 | is_letter_mask = ( 54 | 0 55 | | 1 << UnicodeCategory.UppercaseLetter.value 56 | | 1 << UnicodeCategory.LowercaseLetter.value 57 | | 1 << UnicodeCategory.TitlecaseLetter.value 58 | | 1 << UnicodeCategory.ModifierLetter.value 59 | | 1 << UnicodeCategory.OtherLetter.value 60 | ) 61 | 62 | is_digit_mask = 1 << UnicodeCategory.DecimalDigitNumber.value 63 | 64 | 65 | def is_letter2(s: str, index: int) -> bool: 66 | test = 1 << getUnicodeCategory2(s, index) 67 | return (test & is_letter_mask) != 0 68 | 69 | 70 | def is_digit2(s: str, index: int) -> bool: 71 | test = 1 << getUnicodeCategory2(s, index) 72 | return (test & is_digit_mask) != 0 73 | 74 | 75 | def is_digit(s: str) -> bool: 76 | return s.isdigit() 77 | 78 | 79 | def is_letter(s: str) -> bool: 80 | return s.isalpha() 81 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/date.py: -------------------------------------------------------------------------------- 1 | import re 2 | from datetime import datetime, timedelta, timezone 3 | from typing import Optional 4 | 5 | from .types import FSharpRef 6 | from .util import DateKind 7 | 8 | formatRegExp = re.compile(r"(\w)\1*") 9 | 10 | 11 | def op_subtraction(x: datetime, y: datetime) -> timedelta: 12 | return x - y 13 | 14 | 15 | def create( 16 | year: int, month: int, day: int, h: int = 0, m: int = 0, s: int = 0, ms: int = 0, kind: Optional[DateKind] = None 17 | ) -> datetime: 18 | if kind == DateKind.UTC: 19 | date = datetime( 20 | year=year, month=month, day=day, hour=h, minute=m, second=s, microsecond=ms * 1000, tzinfo=timezone.utc 21 | ) 22 | else: 23 | date = datetime(year, month, day, h, m, s, ms * 1000) 24 | 25 | return date 26 | 27 | 28 | def year(d: datetime) -> int: 29 | return d.year 30 | 31 | 32 | def date_to_string_with_custom_format(date: datetime, format: str, utc) -> str: 33 | def match(m): 34 | match = m.group() 35 | m = match[:1] 36 | print(match) 37 | 38 | rep = None 39 | if m == "y": 40 | y = date.astimezone(timezone.utc).year if utc else date.year 41 | rep = y % 100 if len(match) < 4 else y 42 | elif m == "M": 43 | rep = date.astimezone(timezone.utc).month if utc else date.month 44 | elif m == "H": 45 | rep = date.astimezone(timezone.utc).hour if utc else date.hour 46 | elif m == "m": 47 | rep = date.astimezone(timezone.utc).minute if utc else date.minute 48 | elif m == "s": 49 | rep = date.astimezone(timezone.utc).second if utc else date.second 50 | elif m == "f": 51 | rep = date.astimezone(timezone.utc).microsecond if utc else date.microsecond 52 | rep = rep // 1000 53 | 54 | if rep: 55 | return f"0{rep}" if (rep < 10 and len(match) > 1) else f"{rep}" 56 | else: 57 | return match 58 | return "" 59 | 60 | ret = formatRegExp.sub(match, format) 61 | return ret 62 | 63 | # return format.replace(/(\w)\1*/g, (match) => { 64 | # let rep = Number.NaN; 65 | # switch (match.substring(0, 1)) { 66 | # case "y": 67 | # const y = utc ? date.getUTCFullYear() : date.getFullYear(); 68 | # rep = match.length < 4 ? y % 100 : y; 69 | # break; 70 | # case "M": 71 | # rep = (utc ? date.getUTCMonth() : date.getMonth()) + 1; 72 | # break; 73 | # case "d": 74 | # rep = utc ? date.getUTCDate() : date.getDate(); 75 | # break; 76 | # case "H": 77 | # rep = utc ? date.getUTCHours() : date.getHours(); 78 | # break; 79 | # case "h": 80 | # const h = utc ? date.getUTCHours() : date.getHours(); 81 | # rep = h > 12 ? h % 12 : h; 82 | # break; 83 | # case "m": 84 | # rep = utc ? date.getUTCMinutes() : date.getMinutes(); 85 | # break; 86 | # case "s": 87 | # rep = utc ? date.getUTCSeconds() : date.getSeconds(); 88 | # break; 89 | # case "f": 90 | # rep = utc ? date.getUTCMilliseconds() : date.getMilliseconds(); 91 | # break; 92 | # } 93 | # if (Number.isNaN(rep)) { 94 | # return match; 95 | # } 96 | # else { 97 | # return (rep < 10 && match.length > 1) ? "0" + rep : "" + rep; 98 | # } 99 | 100 | 101 | # def dateToStringWithOffset(date, format=None): 102 | # d = new Date(date.getTime() + ((_a = date.offset) !== null && _a !== void 0 ? _a : 0)); 103 | # if (typeof format !== "string") { 104 | # return d.toISOString().replace(/\.\d+/, "").replace(/[A-Z]|\.\d+/g, " ") + dateOffsetToString(((_b = date.offset) !== null && _b !== void 0 ? _b : 0)); 105 | # } 106 | # else if (format.length === 1) { 107 | # switch (format) { 108 | # case "D": 109 | # case "d": return dateToHalfUTCString(d, "first"); 110 | # case "T": 111 | # case "t": return dateToHalfUTCString(d, "second"); 112 | # case "O": 113 | # case "o": return dateToISOStringWithOffset(d, ((_c = date.offset) !== null && _c !== void 0 ? _c : 0)); 114 | # default: throw new Error("Unrecognized Date print format"); 115 | # } 116 | 117 | # else: 118 | # return dateToStringWithCustomFormat(d, format, True) 119 | 120 | 121 | def date_to_string_with_kind(date: datetime, format: Optional[str] = None) -> str: 122 | utc = date.tzinfo == timezone.utc 123 | if not format: 124 | return date.isoformat() if utc else str(date) 125 | 126 | elif len(format) == 1: 127 | if format == "D" or format == "d": 128 | return dateToHalfUTCString(date, "first") if utc else str(date.date()) 129 | elif format == "T" or format == "t": 130 | return dateToHalfUTCString(date, "second") if utc else str(date.time()) 131 | elif format == "O" or format == "o": 132 | return dateToISOString(date, utc) 133 | else: 134 | raise Exception("Unrecognized Date print format") 135 | 136 | else: 137 | return date_to_string_with_custom_format(date, format, utc) 138 | 139 | 140 | def to_string(date: datetime, format: Optional[str] = None, provider=None) -> str: 141 | if date.tzinfo: 142 | return date_to_string_with_offset(date, format) 143 | 144 | return date_to_string_with_kind(date, format) 145 | 146 | 147 | def now() -> datetime: 148 | return datetime.now() 149 | 150 | 151 | def utc_now() -> datetime: 152 | return datetime.utcnow() 153 | 154 | 155 | def to_local_time(date: datetime) -> datetime: 156 | return date.astimezone() 157 | 158 | 159 | def compare(x: datetime, y: datetime) -> int: 160 | if x == y: 161 | return 0 162 | 163 | if x < y: 164 | return -1 165 | 166 | return 1 167 | 168 | 169 | def equals(x: datetime, y: datetime) -> bool: 170 | return x == y 171 | 172 | 173 | def max_value() -> datetime: 174 | return datetime.max 175 | 176 | 177 | def min_value() -> datetime: 178 | return datetime.min 179 | 180 | 181 | def op_addition(x: datetime, y: datetime) -> datetime: 182 | return x + y 183 | 184 | 185 | def parse(string: str, detectUTC: bool = False) -> datetime: 186 | from dateutil import parser 187 | 188 | return parser.parse(string) 189 | 190 | 191 | def try_parse(string: str, style: int, unsigned: bool, bitsize: int, defValue: FSharpRef[datetime]) -> bool: 192 | try: 193 | defValue.contents = parse(string) 194 | return True 195 | except Exception: 196 | return False 197 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/date_offset.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | from .types import FSharpRef 4 | 5 | 6 | def parse(string: str, detectUTC=False) -> datetime: 7 | from dateutil import parser 8 | 9 | return parser.parse(string) 10 | 11 | 12 | def try_parse(string: str, style: int, unsigned: bool, bitsize: int, defValue: FSharpRef[datetime]) -> bool: 13 | try: 14 | defValue.contents = parse(string) 15 | return True 16 | except Exception: 17 | return False 18 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/decimal.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal, MAX_EMAX, MIN_EMIN 2 | 3 | from .types import FSharpRef 4 | 5 | get_zero = Decimal(0) 6 | 7 | get_one = Decimal(1) 8 | 9 | get_minus_one = Decimal(-1) 10 | 11 | get_max_value = MAX_EMAX 12 | 13 | get_min_value = MIN_EMIN 14 | 15 | 16 | def from_parts(low: int, mid: int, high: int, isNegative: bool, scale: int): 17 | sign = -1 if isNegative else 1 18 | 19 | if low < 0: 20 | low = 0x100000000 + low 21 | 22 | if mid < 0: 23 | mid = 0xFFFFFFFF00000000 + mid + 1 24 | else: 25 | mid = mid << 32 26 | 27 | if high < 0: 28 | high = 0xFFFFFFFF0000000000000000 + high + 1 29 | else: 30 | high = high << 64 31 | 32 | value = Decimal((low + mid + high) * sign) 33 | if scale: 34 | dscale = Decimal(pow(10, scale)) 35 | return value / dscale 36 | return value 37 | 38 | 39 | def op_addition(x: Decimal, y: Decimal): 40 | return x + y 41 | 42 | 43 | def to_string(x: Decimal): 44 | return str(x) 45 | 46 | 47 | def to_number(x: Decimal): 48 | return float(x) 49 | 50 | 51 | def parse(string: str): 52 | return Decimal(string) 53 | 54 | 55 | def try_parse(string: str, defValue: FSharpRef[float]) -> bool: 56 | try: 57 | defValue.contents = parse(string) 58 | return True 59 | except Exception: 60 | return False 61 | 62 | 63 | def equals(a: Decimal, b: Decimal) -> bool: 64 | return a == b 65 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/double.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | from .types import FSharpRef 4 | 5 | 6 | def parse(value: Any) -> float: 7 | try: 8 | return float(value) 9 | except Exception: 10 | raise ValueError("Input string was not in a correct format.") 11 | 12 | 13 | def try_parse(string: str, defValue: FSharpRef[float]) -> bool: 14 | try: 15 | defValue.contents = parse(string) 16 | return True 17 | except Exception: 18 | return False 19 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/fsharp_collections.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from typing import (TypeVar, Callable, Any) 3 | from .util import (IEqualityComparer, structural_hash, equals, physical_hash, compare) 4 | 5 | T = TypeVar("T") 6 | 7 | def HashIdentity_FromFunctions(hash_1: Callable[[T], int], eq: Callable[[T, T], bool]) -> IEqualityComparer[Any]: 8 | class ObjectExpr1: 9 | def Equals(self, x: T, y: T=None, hash_1: Callable[[T], int]=hash_1, eq: Callable[[T, T], bool]=eq) -> bool: 10 | return eq(x, y) 11 | 12 | def GetHashCode(self, x_1: Any=None, hash_1: Callable[[T], int]=hash_1, eq: Callable[[T, T], bool]=eq) -> int: 13 | return hash_1(x_1) 14 | 15 | return ObjectExpr1() 16 | 17 | 18 | def HashIdentity_Structural() -> IEqualityComparer[Any]: 19 | return HashIdentity_FromFunctions(lambda obj=None: structural_hash(obj), lambda e1, e2=None: equals(e1, e2)) 20 | 21 | 22 | def HashIdentity_Reference() -> IEqualityComparer[Any]: 23 | return HashIdentity_FromFunctions(lambda obj=None: physical_hash(obj), lambda e1, e2=None: e1 is e2) 24 | 25 | 26 | def ComparisonIdentity_FromFunction(comparer: Callable[[T, T], int]) -> IComparer_1[T]: 27 | class ObjectExpr4: 28 | def Compare(self, x: T, y: T=None, comparer: Callable[[T, T], int]=comparer) -> int: 29 | return comparer(x, y) 30 | 31 | return ObjectExpr4() 32 | 33 | 34 | def ComparisonIdentity_Structural() -> IComparer_1[Any]: 35 | return ComparisonIdentity_FromFunction(lambda e1, e2=None: compare(e1, e2)) 36 | 37 | 38 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/fsharp_core.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from typing import (Any, Optional, TypeVar, Callable) 3 | from .fsharp_collections import (ComparisonIdentity_Structural, HashIdentity_Structural) 4 | from .system_text import (StringBuilder, StringBuilder__Append_Z721C83C5) 5 | from .util import (equals, structural_hash, IEqualityComparer, IDisposable, dispose, ignore) 6 | 7 | a_ = TypeVar("a_") 8 | 9 | b_ = TypeVar("b_") 10 | 11 | class ObjectExpr1: 12 | def System_Collections_IEqualityComparer_Equals541DA560(self, x: Any, y: Any) -> bool: 13 | return equals(x, y) 14 | 15 | def System_Collections_IEqualityComparer_GetHashCode4E60E31B(self, x_1: Any) -> int: 16 | return structural_hash(x_1) 17 | 18 | 19 | LanguagePrimitives_GenericEqualityComparer : IEqualityComparer = ObjectExpr1() 20 | 21 | class ObjectExpr2: 22 | def System_Collections_IEqualityComparer_Equals541DA560(self, x: Any, y: Any) -> bool: 23 | return equals(x, y) 24 | 25 | def System_Collections_IEqualityComparer_GetHashCode4E60E31B(self, x_1: Any) -> int: 26 | return structural_hash(x_1) 27 | 28 | 29 | LanguagePrimitives_GenericEqualityERComparer : IEqualityComparer = ObjectExpr2() 30 | 31 | def LanguagePrimitives_FastGenericComparer() -> IComparer_1[Any]: 32 | return ComparisonIdentity_Structural() 33 | 34 | 35 | def LanguagePrimitives_FastGenericComparerFromTable() -> IComparer_1[Any]: 36 | return ComparisonIdentity_Structural() 37 | 38 | 39 | def LanguagePrimitives_FastGenericEqualityComparer() -> IEqualityComparer[Any]: 40 | return HashIdentity_Structural() 41 | 42 | 43 | def LanguagePrimitives_FastGenericEqualityComparerFromTable() -> IEqualityComparer[Any]: 44 | return HashIdentity_Structural() 45 | 46 | 47 | def Operators_Failure(message: str) -> Exception: 48 | return Exception(message) 49 | 50 | 51 | def Operators_FailurePattern(exn: Exception) -> Optional[str]: 52 | return str(exn) 53 | 54 | 55 | def Operators_NullArg(x: str) -> Any: 56 | raise Exception(x) 57 | 58 | 59 | def Operators_Using(resource: IDisposable, action: Callable[[IDisposable], a_]) -> a_: 60 | try: 61 | return action(resource) 62 | 63 | finally: 64 | if equals(resource, None): 65 | pass 66 | 67 | else: 68 | dispose(resource) 69 | 70 | 71 | 72 | 73 | def Operators_Lock(_lockObj: Any, action: Callable[[], b_]) -> b_: 74 | return action() 75 | 76 | 77 | def ExtraTopLevelOperators_LazyPattern(input: Any) -> a_: 78 | return input.Value 79 | 80 | 81 | def PrintfModule_PrintFormatToStringBuilderThen(continuation: Callable[[], a_], builder: StringBuilder, format: Any) -> b_: 82 | def append(s: str, continuation: Callable[[], a_]=continuation, builder: StringBuilder=builder, format: Any=format) -> Any: 83 | ignore(StringBuilder__Append_Z721C83C5(builder, s)) 84 | return continuation() 85 | 86 | return format.cont(append) 87 | 88 | 89 | def PrintfModule_PrintFormatToStringBuilder(builder: StringBuilder, format: Any) -> a_: 90 | def arrow_10(builder: StringBuilder=builder, format: Any=format) -> None: 91 | ignore() 92 | 93 | return PrintfModule_PrintFormatToStringBuilderThen(arrow_10, builder, format) 94 | 95 | 96 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/global_.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import (TypeVar, Generic, Any) 3 | 4 | T = TypeVar("T") 5 | 6 | class IGenericAdder_1(Generic[T]): 7 | @abstractmethod 8 | def Add(self, __arg0: T, __arg1: T) -> T: 9 | ... 10 | 11 | @abstractmethod 12 | def GetZero(self) -> T: 13 | ... 14 | 15 | 16 | class IGenericAverager_1(Generic[T]): 17 | @abstractmethod 18 | def Add(self, __arg0: T, __arg1: T) -> T: 19 | ... 20 | 21 | @abstractmethod 22 | def DivideByInt(self, __arg0: T, __arg1: int) -> T: 23 | ... 24 | 25 | @abstractmethod 26 | def GetZero(self) -> T: 27 | ... 28 | 29 | 30 | class Symbol_wellknown: 31 | @property 32 | @abstractmethod 33 | def Symbol_toStringTag(self) -> str: 34 | ... 35 | 36 | 37 | class IJsonSerializable: 38 | @abstractmethod 39 | def to_json(self, key: str) -> Any: 40 | ... 41 | 42 | 43 | SR_indexOutOfBounds : str = "The index was outside the range of elements in the collection." 44 | 45 | SR_inputWasEmpty : str = "Collection was empty." 46 | 47 | SR_inputMustBeNonNegative : str = "The input must be non-negative." 48 | 49 | SR_inputSequenceEmpty : str = "The input sequence was empty." 50 | 51 | SR_inputSequenceTooLong : str = "The input sequence contains more than one element." 52 | 53 | SR_keyNotFoundAlt : str = "An index satisfying the predicate was not found in the collection." 54 | 55 | SR_differentLengths : str = "The collections had different lengths." 56 | 57 | SR_notEnoughElements : str = "The input sequence has an insufficient number of elements." 58 | 59 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/guid.py: -------------------------------------------------------------------------------- 1 | import uuid 2 | from .types import FSharpRef 3 | 4 | 5 | def parse(string: str) -> uuid.UUID: 6 | return uuid.UUID(string) 7 | 8 | 9 | def try_parse(string: str, def_value: FSharpRef[uuid.UUID]) -> bool: 10 | try: 11 | def_value.contents = parse(string) 12 | return True 13 | except Exception: 14 | return False 15 | 16 | 17 | def to_string(guid: uuid.UUID): 18 | return str(guid) 19 | 20 | 21 | def new_guid(): 22 | return uuid.uuid4() 23 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/int32.py: -------------------------------------------------------------------------------- 1 | from typing import Tuple 2 | from .types import FSharpRef 3 | 4 | 5 | def get_range(unsigned: bool, bitsize: int) -> Tuple[int, int]: 6 | if bitsize == 8: 7 | return (0, 255) if unsigned else (-128, 127) 8 | if bitsize == 16: 9 | return (0, 65535) if unsigned else (-32768, 32767) 10 | if bitsize == 32: 11 | return (0, 4294967295) if unsigned else (-2147483648, 2147483647) 12 | raise ValueError("Invalid bit size.") 13 | 14 | 15 | AllowHexSpecifier = 0x00000200 16 | 17 | 18 | def parse(string: str, style, unsigned, bitsize, radix: int = 10) -> int: 19 | # const res = isValid(str, style, radix); 20 | if style & AllowHexSpecifier or string.startswith("0x"): 21 | radix = 16 22 | elif string.startswith("0b"): 23 | radix = 2 24 | elif string.startswith("0o"): 25 | radix = 8 26 | 27 | try: 28 | v = int(string, base=radix) 29 | except Exception: 30 | raise ValueError("Input string was not in a correct format.") 31 | 32 | (umin, umax) = get_range(True, bitsize) 33 | if not unsigned and radix != 10 and v >= umin and v <= umax: 34 | mask = 1 << (bitsize - 1) 35 | if v & mask: # Test if negative 36 | v = v - (mask << 1) 37 | 38 | (min, max) = get_range(unsigned, bitsize) 39 | if v >= min and v <= max: 40 | return v 41 | 42 | raise ValueError("Input string was not in a correct format.") 43 | 44 | 45 | def try_parse(string: str, style: int, unsigned: bool, bitsize: int, defValue: FSharpRef[int]) -> bool: 46 | try: 47 | defValue.contents = parse(string, style, unsigned, bitsize) 48 | return True 49 | except Exception: 50 | return False 51 | 52 | 53 | def op_unary_negation_int8(x): 54 | return x if x == -128 else -x 55 | 56 | 57 | def op_unary_negation_int16(x): 58 | return x if x == -32768 else -x 59 | 60 | 61 | def op_unary_negation_int32(x): 62 | return x if x == -2147483648 else -x 63 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/long.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Optional, Tuple 2 | 3 | from .types import FSharpRef 4 | 5 | 6 | def from_bits(lowBits: int, highBits: int, unsigned: bool): 7 | ret = lowBits + (highBits << 32) 8 | if not unsigned and ret > 0x7FFFFFFFFFFFFFFF: 9 | return ret - 0x10000000000000000 10 | 11 | return ret 12 | 13 | 14 | def from_int(value: int, unsigned: bool = False): 15 | if unsigned and value < 0: 16 | return value + 0x10000000000000000 17 | return value 18 | 19 | 20 | def from_value(value: Any, unsigned: bool = False): 21 | value = int(value) 22 | if unsigned and value < 0: 23 | return value + 0x10000000000000000 24 | elif not unsigned and value > 9223372036854775807: 25 | return value - 0x10000000000000000 26 | 27 | return value 28 | 29 | 30 | def from_number(value, unsigned: bool): 31 | return int(value) 32 | 33 | 34 | def to_number(value: int) -> float: 35 | return float(value) 36 | 37 | 38 | def from_integer(value: int, unsigned: bool = None, kind: int = None) -> int: 39 | if unsigned and value < 0: 40 | return value + 0x10000000000000000 41 | elif not unsigned and value > 9223372036854775807: 42 | return value - 0x10000000000000000 43 | return value 44 | 45 | 46 | def op_left_shift(self, numBits): 47 | return self << numBits 48 | 49 | 50 | def op_addition(a, b): 51 | return a + b 52 | 53 | 54 | def op_multiply(a, b): 55 | return a * b 56 | 57 | 58 | def op_unary_negation(value): 59 | return -value 60 | 61 | 62 | def get_range(unsigned: bool) -> Tuple[int, int]: 63 | return (0, 18446744073709551615) if unsigned else (-9223372036854775808, 9223372036854775807) 64 | 65 | 66 | AllowHexSpecifier = 0x00000200 67 | 68 | 69 | def parse(string: str, style, unsigned, bitsize, radix: int = 10) -> int: 70 | # const res = isValid(str, style, radix); 71 | if style & AllowHexSpecifier or string.startswith("0x"): 72 | radix = 16 73 | elif string.startswith("0b"): 74 | radix = 2 75 | elif string.startswith("0o"): 76 | radix = 8 77 | 78 | try: 79 | v = int(string, base=radix) 80 | except Exception: 81 | raise ValueError("Input string was not in a correct format.") 82 | 83 | (umin, umax) = get_range(True) 84 | if not unsigned and radix != 10 and v >= umin and v <= umax: 85 | mask = 1 << (bitsize - 1) 86 | if v & mask: # Test if negative 87 | v = v - (mask << 1) 88 | 89 | (min, max) = get_range(unsigned) 90 | if v >= min and v <= max: 91 | return v 92 | 93 | raise ValueError("Input string was not in a correct format.") 94 | 95 | 96 | def try_parse(string: str, style: int, unsigned: bool, bitsize: int, defValue: FSharpRef[int]) -> bool: 97 | try: 98 | defValue.contents = parse(string, style, unsigned, bitsize) 99 | return True 100 | except Exception: 101 | return False 102 | 103 | 104 | def to_string(x: int): 105 | return str(x) 106 | 107 | 108 | def to_int(value: int): 109 | if value > 9223372036854775807: 110 | return value - 0x10000000000000000 111 | return value 112 | 113 | 114 | def compare(a, b): 115 | return 0 if a == b else -1 if a < b else 1 116 | 117 | 118 | def equals(a, b): 119 | return a == b 120 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/mailbox_processor.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from queue import SimpleQueue 4 | from threading import RLock 5 | from typing import Optional, Callable, TypeVar, Generic, Any, List 6 | 7 | from .async_builder import CancellationToken, IAsync, OperationCanceledError 8 | from .async_ import start_immediate, from_continuations 9 | 10 | 11 | Msg = TypeVar("Msg") 12 | Reply = TypeVar("Reply") 13 | 14 | 15 | class AsyncReplyChannel(Generic[Reply]): 16 | def __init__(self, fn: Callable[[Any], None]) -> None: 17 | self.fn = fn 18 | 19 | def reply(self, r: Any) -> None: 20 | self.fn(r) 21 | 22 | 23 | class MailboxProcessor(Generic[Msg]): 24 | def __init__( 25 | self, body: Callable[[MailboxProcessor[Msg]], None], cancellation_token: Optional[CancellationToken] = None 26 | ): 27 | self.messages: SimpleQueue[Msg] = SimpleQueue() 28 | self.token = cancellation_token or CancellationToken() 29 | self.lock = RLock() 30 | self.body = body 31 | 32 | # Holds the continuation i.e the `done` callback of Async.from_continuations returned by `receive`. 33 | self.continuation = None 34 | 35 | def post(self, msg: Msg) -> None: 36 | """Post a message synchronously to the mailbox processor. 37 | 38 | This method is not asynchronous since it's very fast to execute. 39 | It simply adds the message to the message queue of the mailbox 40 | processor and returns. 41 | 42 | Args: 43 | msg: Message to post. 44 | 45 | Returns: 46 | None 47 | """ 48 | self.messages.put(msg) 49 | self.__process_events() 50 | 51 | def post_and_async_reply(self, build_message: Callable[[AsyncReplyChannel[Reply]], Msg]) -> IAsync[Reply]: 52 | """Post a message asynchronously to the mailbox processor and 53 | wait for the reply. 54 | 55 | Args: 56 | build_message: A function that takes a reply channel 57 | (`AsyncReplyChannel[Reply]`) and returns a message to send 58 | to the mailbox processor. The message should contain the 59 | reply channel as e.g a tuple. 60 | 61 | Returns: 62 | The reply from mailbox processor. 63 | """ 64 | 65 | result = None 66 | continuation = None # This is the continuation for the `done` callback of the awaiting poster. 67 | 68 | def check_completion() -> None: 69 | if result is not None and continuation is not None: 70 | continuation(result) 71 | 72 | def reply_callback(res: Reply): 73 | nonlocal result 74 | result = res 75 | check_completion() 76 | 77 | reply_channel: AsyncReplyChannel[Reply] = AsyncReplyChannel(reply_callback) 78 | self.messages.put(build_message(reply_channel)) 79 | self.__process_events() 80 | 81 | def callback(conts: List[Callable[[Any], None]]) -> None: 82 | nonlocal continuation 83 | continuation = conts 84 | check_completion() 85 | 86 | return from_continuations(callback) 87 | 88 | def receive(self) -> IAsync[Msg]: 89 | """Receive message from mailbox. 90 | 91 | Returns: 92 | An asynchronous computation which will consume the 93 | first message in arrival order. No thread is blocked while 94 | waiting for further messages. Raises a TimeoutException if 95 | the timeout is exceeded. 96 | """ 97 | 98 | def callback(conts: List[Callable[[Any], None]]): 99 | if self.continuation: 100 | raise Exception("Receive can only be called once!") 101 | 102 | self.continuation = conts 103 | 104 | self.__process_events() 105 | 106 | return from_continuations(callback) 107 | 108 | def __process_events(self) -> None: 109 | # Cancellation of async workflows is more tricky in Python than 110 | # with F# so we check the cancellation token for each process. 111 | if self.token.is_cancellation_requested: 112 | self.continuation, cont = None, self.continuation 113 | if cont is not None: 114 | cont[2](OperationCanceledError("Mailbox was cancelled")) 115 | return 116 | 117 | if self.continuation is None: 118 | return 119 | 120 | with self.lock: 121 | if self.messages.empty(): 122 | return 123 | msg = self.messages.get() 124 | self.continuation, cont = None, self.continuation 125 | 126 | if cont is not None: 127 | cont[0](msg) 128 | 129 | @staticmethod 130 | def start( 131 | body: Callable[[MailboxProcessor[Msg]], None], cancellation_token: Optional[CancellationToken] = None 132 | ) -> MailboxProcessor[Msg]: 133 | mbox: MailboxProcessor[Msg] = MailboxProcessor(body, cancellation_token) 134 | start_immediate(body(mbox)) 135 | return mbox 136 | 137 | 138 | def receive(mbox: MailboxProcessor[Msg]) -> IAsync[Msg]: 139 | return mbox.receive() 140 | 141 | 142 | def post(mbox: MailboxProcessor[Msg], msg: Msg): 143 | return mbox.post(msg) 144 | 145 | 146 | def start_instance(mbox: MailboxProcessor[Any]) -> IAsync[Any]: 147 | return start_immediate(mbox.body(mbox)) 148 | 149 | 150 | def start( 151 | body: Callable[[MailboxProcessor[Msg]], None], cancellationToken: Optional[CancellationToken] = None 152 | ) -> MailboxProcessor[Msg]: 153 | mbox = MailboxProcessor(body, cancellationToken) 154 | start_instance(mbox) 155 | return mbox 156 | 157 | 158 | __all__ = ["AsyncReplyChannel", "MailboxProcessor", "receive", "post", "start", "start_instance"] 159 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/map_util.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | 4 | def add_to_set(v: Any, st: set) -> bool: 5 | if v in st: 6 | return False 7 | 8 | st.add(v) 9 | return True 10 | 11 | 12 | def add_to_dict(di, k: Any, v: Any) -> None: 13 | if k in di: 14 | raise Exception("An item with the same key has already been added. Key: " + str(k)) 15 | 16 | di[k] = v 17 | 18 | 19 | def try_get_value(map: dict, key: Any, default_value: Any) -> bool: 20 | if key in map: 21 | default_value.contents = map.get(key) 22 | return True 23 | 24 | return False 25 | 26 | 27 | def get_item_from_dict(map: dict, key: Any) -> Any: 28 | if key in map: 29 | return map.get(key) 30 | else: 31 | raise Exception(f"The given key '{key}' was not present in the dictionary.") 32 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/native.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from abc import abstractmethod 3 | from typing import (TypeVar, List, Generic, Any) 4 | 5 | T = TypeVar("T") 6 | 7 | class Cons_1(Generic[T]): 8 | @abstractmethod 9 | def Allocate(self, len: int) -> List[T]: 10 | ... 11 | 12 | 13 | def Helpers_allocateArrayFromCons(cons: Cons_1[T], len_1: int) -> List[T]: 14 | if cons is None: 15 | return (list)([None]*len_1) 16 | 17 | else: 18 | return cons([0]*len_1) 19 | 20 | 21 | 22 | def Helpers_fillImpl(array: List[T], value: T, start: int, count: int) -> List[T]: 23 | for i in range(0, (count - 1) + 1, 1): 24 | array[i + start] = value 25 | return array 26 | 27 | 28 | def Helpers_spliceImpl(array: List[T], start: int, delete_count: int) -> List[T]: 29 | for _ in range(1, delete_count + 1, 1): 30 | array.pop(start) 31 | return array 32 | 33 | 34 | def Helpers_indexOfImpl(array: List[T], item: T, start: int) -> Any: 35 | try: 36 | return array.index(item, start) 37 | 38 | except Exception as ex: 39 | return -1 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/numeric.py: -------------------------------------------------------------------------------- 1 | def to_fixed(x: float, dp=None) -> str: 2 | if dp is not None: 3 | fmt = "{:.%sf}" % dp 4 | return fmt.format(x) 5 | 6 | return "{}".format(x) 7 | 8 | 9 | def to_precision(x: float, sd=None): 10 | if sd is not None: 11 | fmt = "{:.%se}" % sd 12 | return fmt.format(x) 13 | 14 | return "{}".format(x) 15 | 16 | 17 | def to_exponential(x: float, dp=None): 18 | if dp is not None: 19 | fmt = "{:.%se}" % dp 20 | return fmt.format(x) 21 | 22 | return "{}".format(x) 23 | 24 | 25 | def to_hex(x) -> str: 26 | return "{0:x}".format(x) 27 | 28 | 29 | def multiply(x: int, y: int): 30 | return x * y 31 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/option.py: -------------------------------------------------------------------------------- 1 | from typing import TypeVar, Generic, Any, Optional, Union, List, Callable 2 | 3 | T = TypeVar("T") 4 | U = TypeVar("U") 5 | V = TypeVar("V") 6 | 7 | 8 | class Some(Generic[T]): 9 | def __init__(self, value: T): 10 | self.value = value 11 | 12 | def __eq__(self, other: Any) -> bool: 13 | if self is other: 14 | return True 15 | 16 | if other is None: 17 | return False 18 | 19 | if self.value == other.value: 20 | return True 21 | 22 | return False 23 | 24 | def __str__(self): 25 | return f"Some {self.value}" 26 | 27 | def __repr__(self): 28 | return str(self) 29 | 30 | 31 | Option = Union[Some[T], Any] 32 | 33 | 34 | def default_arg(opt: Option[T], default_value: T) -> T: 35 | return value(opt) if opt is not None else default_value 36 | 37 | 38 | def default_arg_with(opt: Option[T], def_thunk: Callable[[], T]) -> T: 39 | return value(opt) if opt is not None else def_thunk() 40 | 41 | 42 | def filter(predicate: Callable[[T], bool], opt: Option[T]) -> Option[T]: 43 | if opt is not None: 44 | return opt if predicate(value(opt)) else None 45 | return opt 46 | 47 | 48 | def map(mapping: Callable[[T], U], opt: Option[T]) -> Option[U]: 49 | return some(mapping(value(opt))) if opt is not None else None 50 | 51 | 52 | def map2(mapping: Callable[[T, U], V], opt1: Optional[T], opt2: Optional[U]) -> Optional[V]: 53 | return mapping(value(opt1), value(opt2)) if (opt1 is not None and opt2 is not None) else None 54 | 55 | 56 | def map3(mapping, opt1, opt2, opt3): 57 | return ( 58 | mapping(value(opt1), value(opt2), value(opt3)) 59 | if (opt1 is not None and opt2 is not None and opt3 is not None) 60 | else None 61 | ) 62 | 63 | 64 | def some(x: T) -> Option[T]: 65 | return Some(x) if x is None or isinstance(x, Some) else x 66 | 67 | 68 | def value(x: Option[T]) -> T: 69 | if x is None: 70 | raise Exception("Option has no value") 71 | else: 72 | return x.value if isinstance(x, Some) else x 73 | 74 | 75 | def of_nullable(x: Optional[T]) -> Option[T]: 76 | return x 77 | 78 | 79 | def to_nullable(x: Option[T]) -> Optional[T]: 80 | return None if x is None else value(x) 81 | 82 | 83 | def flatten(x: Option[Option[T]]) -> Option[T]: 84 | return None if x is None else value(x) 85 | 86 | 87 | def to_array(opt: Option[T]) -> List[T]: 88 | return [] if opt is None else [value(opt)] 89 | 90 | 91 | def bind(binder: Callable[[T], Option[U]], opt: Option[T]) -> Option[U]: 92 | return binder(value(opt)) if opt is not None else None 93 | 94 | 95 | __all__ = [ 96 | "bind", 97 | "default_arg", 98 | "default_arg_with", 99 | "flatten", 100 | "map", 101 | "map2", 102 | "map3", 103 | "of_nullable", 104 | "some", 105 | "Some", 106 | "to_array", 107 | "to_nullable", 108 | "value", 109 | ] 110 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/range.py: -------------------------------------------------------------------------------- 1 | from typing import (TypeVar, Callable, Tuple, Optional, Any, Iterable) 2 | from .big_int import (from_zero, op_addition) 3 | from .decimal import (from_parts, op_addition as op_addition_1) 4 | from .long import (from_bits, op_addition as op_addition_2) 5 | from .seq import (delay, unfold) 6 | from .util import compare 7 | 8 | T = TypeVar("T") 9 | 10 | def make_range_step_function(step: T, stop: T, zero: T, add: Callable[[T, T], T]) -> Callable[[T], Optional[Tuple[T, T]]]: 11 | step_compared_with_zero : int = compare(step, zero) or 0 12 | if step_compared_with_zero == 0: 13 | raise Exception("The step of a range cannot be zero") 14 | 15 | step_greater_than_zero : bool = step_compared_with_zero > 0 16 | def arrow_9(x: T=None, step: T=step, stop: T=stop, zero: T=zero, add: Callable[[T, T], T]=add) -> Optional[Tuple[T, T]]: 17 | compared_with_last : int = compare(x, stop) or 0 18 | return (x, add(x, step)) if (True if (compared_with_last <= 0 if (step_greater_than_zero) else (False)) else (compared_with_last >= 0 if (not step_greater_than_zero) else (False))) else (None) 19 | 20 | return arrow_9 21 | 22 | 23 | def integral_range_step(start: T, step: T, stop: T, zero: T, add: Callable[[T, T], T]) -> Iterable[T]: 24 | step_fn : Callable[[T], Optional[Tuple[T, T]]] = make_range_step_function(step, stop, zero, add) 25 | return delay(lambda start=start, step=step, stop=stop, zero=zero, add=add: unfold(step_fn, start)) 26 | 27 | 28 | def range_big_int(start: Any, step: Any, stop: Any) -> Iterable[Any]: 29 | return integral_range_step(start, step, stop, from_zero(), lambda x, y, start=start, step=step, stop=stop: op_addition(x, y)) 30 | 31 | 32 | def range_decimal(start: Any, step: Any, stop: Any) -> Iterable[Any]: 33 | return integral_range_step(start, step, stop, from_parts(0, 0, 0, False, 0), lambda x, y, start=start, step=step, stop=stop: op_addition_1(x, y)) 34 | 35 | 36 | def range_double(start: float, step: float, stop: float) -> Iterable[float]: 37 | return integral_range_step(start, step, stop, 0, lambda x, y, start=start, step=step, stop=stop: x + y) 38 | 39 | 40 | def range_int64(start: Any, step: Any, stop: Any) -> Iterable[Any]: 41 | return integral_range_step(start, step, stop, from_bits(0, 0, False), lambda x, y, start=start, step=step, stop=stop: op_addition_2(x, y)) 42 | 43 | 44 | def range_uint64(start: Any, step: Any, stop: Any) -> Iterable[Any]: 45 | return integral_range_step(start, step, stop, from_bits(0, 0, True), lambda x, y, start=start, step=step, stop=stop: op_addition_2(x, y)) 46 | 47 | 48 | def range_char(start: str, stop: str) -> Iterable[str]: 49 | int_stop : int = ord(stop) or 0 50 | def arrow_12(start: str=start, stop: str=stop) -> Iterable[str]: 51 | def step_fn(c: int) -> Optional[Tuple[str, int]]: 52 | if c <= int_stop: 53 | return (chr(c), c + 1) 54 | 55 | else: 56 | return None 57 | 58 | 59 | return unfold(step_fn, ord(start)) 60 | 61 | return delay(arrow_12) 62 | 63 | 64 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/reg_exp.py: -------------------------------------------------------------------------------- 1 | import re 2 | from typing import Pattern, Union 3 | 4 | 5 | def escape(string: str) -> str: 6 | return re.escape(string) 7 | 8 | 9 | def is_match(string: str, pattern: str) -> bool: 10 | return re.match(pattern, string) is not None 11 | 12 | 13 | def replace(reg: Union[str, Pattern], input: str, replacement: str) -> str: 14 | if isinstance(reg, str): 15 | return re.sub(input, replacement, reg) 16 | else: 17 | return reg.sub(input, replacement) 18 | 19 | 20 | def create(pattern: str, options: int = 0) -> Pattern: 21 | return re.compile(pattern) 22 | 23 | 24 | __all__ = ["escape", "is_match", "create", "replace"] 25 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/seq2.py: -------------------------------------------------------------------------------- 1 | from typing import (TypeVar, Iterable, Any, Callable, List, Tuple) 2 | from .list import FSharpList 3 | from .map_util import (add_to_set, try_get_value, get_item_from_dict, add_to_dict) 4 | from .mutable_map import Dictionary 5 | from .mutable_set import HashSet 6 | from .seq import (delay, filter, map, to_array, to_list) 7 | from .types import FSharpRef 8 | from .util import (IEqualityComparer, get_enumerator) 9 | 10 | T = TypeVar("T") 11 | 12 | Key = TypeVar("Key") 13 | 14 | def distinct(xs: Iterable[T], comparer: IEqualityComparer[Any]) -> Iterable[T]: 15 | def arrow_5(xs: Iterable[T]=xs, comparer: IEqualityComparer[Any]=comparer) -> Iterable[Any]: 16 | hash_set : Any = HashSet([], comparer) 17 | return filter(lambda x=None: add_to_set(x, hash_set), xs) 18 | 19 | return delay(arrow_5) 20 | 21 | 22 | def distinct_by(projection: Callable[[T], Key], xs: Iterable[T], comparer: IEqualityComparer[Any]) -> Iterable[T]: 23 | def arrow_6(projection: Callable[[T], Key]=projection, xs: Iterable[T]=xs, comparer: IEqualityComparer[Any]=comparer) -> Iterable[Any]: 24 | hash_set : Any = HashSet([], comparer) 25 | return filter(lambda x=None: add_to_set(projection(x), hash_set), xs) 26 | 27 | return delay(arrow_6) 28 | 29 | 30 | def except_(items_to_exclude: Iterable[T], xs: Iterable[T], comparer: IEqualityComparer[Any]) -> Iterable[T]: 31 | def arrow_7(items_to_exclude: Iterable[T]=items_to_exclude, xs: Iterable[T]=xs, comparer: IEqualityComparer[Any]=comparer) -> Iterable[Any]: 32 | hash_set : Any = HashSet(items_to_exclude, comparer) 33 | return filter(lambda x=None: add_to_set(x, hash_set), xs) 34 | 35 | return delay(arrow_7) 36 | 37 | 38 | def count_by(projection: Callable[[T], Key], xs: Iterable[T], comparer: IEqualityComparer[Any]) -> Iterable[Tuple[Key, int]]: 39 | def arrow_13(projection: Callable[[T], Key]=projection, xs: Iterable[T]=xs, comparer: IEqualityComparer[Any]=comparer) -> Iterable[Tuple[Key, int]]: 40 | dict_1 : Any = Dictionary([], comparer) 41 | keys : List[Key] = [] 42 | with get_enumerator(xs) as enumerator: 43 | while enumerator.System_Collections_IEnumerator_MoveNext(): 44 | key : Key = projection(enumerator.System_Collections_Generic_IEnumerator_00601_get_Current()) 45 | match_value = None 46 | out_arg : int = 0 47 | def arrow_8(v: int) -> None: 48 | nonlocal out_arg 49 | out_arg = v or 0 50 | 51 | match_value = (try_get_value(dict_1, key, FSharpRef(lambda _unit=None: out_arg, arrow_8)), out_arg) 52 | if match_value[0]: 53 | dict_1[key] = match_value[1] + 1 54 | 55 | else: 56 | dict_1[key] = 1 57 | (keys.append(key)) 58 | 59 | return map(lambda key_1=None: (key_1, get_item_from_dict(dict_1, key_1)), keys) 60 | 61 | return delay(arrow_13) 62 | 63 | 64 | def group_by(projection: Callable[[T], Key], xs: Iterable[T], comparer: IEqualityComparer[Any]) -> Iterable[Tuple[Key, Iterable[T]]]: 65 | def arrow_15(projection: Callable[[T], Key]=projection, xs: Iterable[T]=xs, comparer: IEqualityComparer[Any]=comparer) -> Iterable[Tuple[Key, Iterable[T]]]: 66 | dict_1 : Any = Dictionary([], comparer) 67 | keys : List[Key] = [] 68 | with get_enumerator(xs) as enumerator: 69 | while enumerator.System_Collections_IEnumerator_MoveNext(): 70 | x : T = enumerator.System_Collections_Generic_IEnumerator_00601_get_Current() 71 | key : Key = projection(x) 72 | match_value = None 73 | out_arg : List[T] = None 74 | def arrow_14(v: List[T]) -> None: 75 | nonlocal out_arg 76 | out_arg = v 77 | 78 | match_value = (try_get_value(dict_1, key, FSharpRef(lambda _unit=None: out_arg, arrow_14)), out_arg) 79 | if match_value[0]: 80 | (match_value[1].append(x)) 81 | 82 | else: 83 | add_to_dict(dict_1, key, [x]) 84 | (keys.append(key)) 85 | 86 | return map(lambda key_1=None: (key_1, get_item_from_dict(dict_1, key_1)), keys) 87 | 88 | return delay(arrow_15) 89 | 90 | 91 | def Array_distinct(xs: List[T], comparer: IEqualityComparer[Any]) -> List[T]: 92 | return to_array(distinct(xs, comparer)) 93 | 94 | 95 | def Array_distinctBy(projection: Callable[[T], Key], xs: List[T], comparer: IEqualityComparer[Any]) -> List[T]: 96 | return to_array(distinct_by(projection, xs, comparer)) 97 | 98 | 99 | def Array_except(items_to_exclude: Iterable[T], xs: List[T], comparer: IEqualityComparer[Any]) -> List[T]: 100 | return to_array(except_(items_to_exclude, xs, comparer)) 101 | 102 | 103 | def Array_countBy(projection: Callable[[T], Key], xs: List[T], comparer: IEqualityComparer[Any]) -> List[Tuple[Key, int]]: 104 | return to_array(count_by(projection, xs, comparer)) 105 | 106 | 107 | def Array_groupBy(projection: Callable[[T], Key], xs: List[T], comparer: IEqualityComparer[Any]) -> List[Tuple[Key, List[T]]]: 108 | return to_array(map(lambda tupled_arg, projection=projection, xs=xs, comparer=comparer: (tupled_arg[0], to_array(tupled_arg[1])), group_by(projection, xs, comparer))) 109 | 110 | 111 | def List_distinct(xs: FSharpList[T], comparer: IEqualityComparer[Any]) -> FSharpList[T]: 112 | return to_list(distinct(xs, comparer)) 113 | 114 | 115 | def List_distinctBy(projection: Callable[[T], Key], xs: FSharpList[T], comparer: IEqualityComparer[Any]) -> FSharpList[T]: 116 | return to_list(distinct_by(projection, xs, comparer)) 117 | 118 | 119 | def List_except(items_to_exclude: Iterable[T], xs: FSharpList[T], comparer: IEqualityComparer[Any]) -> FSharpList[T]: 120 | return to_list(except_(items_to_exclude, xs, comparer)) 121 | 122 | 123 | def List_countBy(projection: Callable[[T], Key], xs: FSharpList[T], comparer: IEqualityComparer[Any]) -> FSharpList[Tuple[Key, int]]: 124 | return to_list(count_by(projection, xs, comparer)) 125 | 126 | 127 | def List_groupBy(projection: Callable[[T], Key], xs: FSharpList[T], comparer: IEqualityComparer[Any]) -> FSharpList[Tuple[Key, FSharpList[T]]]: 128 | return to_list(map(lambda tupled_arg, projection=projection, xs=xs, comparer=comparer: (tupled_arg[0], to_list(tupled_arg[1])), group_by(projection, xs, comparer))) 129 | 130 | 131 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/system_text.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from typing import (Any, List) 3 | from .reflection import (TypeInfo, class_type) 4 | from .string import (join, is_null_or_empty, format, substring) 5 | from .types import to_string 6 | from .util import (int32_to_string, clear) 7 | 8 | def expr_11() -> TypeInfo: 9 | return class_type("System.Text.StringBuilder", None, StringBuilder) 10 | 11 | 12 | class StringBuilder: 13 | def __init__(self, value: str, capacity: int) -> None: 14 | self.buf = [] 15 | if not is_null_or_empty(value): 16 | (self.buf.append(value)) 17 | 18 | 19 | def __str__(self) -> str: 20 | __ : StringBuilder = self 21 | return join("", __.buf) 22 | 23 | 24 | StringBuilder_reflection = expr_11 25 | 26 | def StringBuilder__ctor_Z18115A39(value: str, capacity: int) -> StringBuilder: 27 | return StringBuilder(value, capacity) 28 | 29 | 30 | def StringBuilder__ctor_Z524259A4(capacity: int) -> StringBuilder: 31 | return StringBuilder__ctor_Z18115A39("", capacity) 32 | 33 | 34 | def StringBuilder__ctor_Z721C83C5(value: str) -> StringBuilder: 35 | return StringBuilder__ctor_Z18115A39(value, 16) 36 | 37 | 38 | def StringBuilder__ctor() -> StringBuilder: 39 | return StringBuilder__ctor_Z18115A39("", 16) 40 | 41 | 42 | def StringBuilder__Append_Z721C83C5(x: StringBuilder, s: str) -> StringBuilder: 43 | (x.buf.append(s)) 44 | return x 45 | 46 | 47 | def StringBuilder__Append_244C7CD6(x: StringBuilder, c: str) -> StringBuilder: 48 | (x.buf.append(c)) 49 | return x 50 | 51 | 52 | def StringBuilder__Append_Z524259A4(x: StringBuilder, o: int) -> StringBuilder: 53 | (x.buf.append(int32_to_string(o))) 54 | return x 55 | 56 | 57 | def StringBuilder__Append_5E38073B(x: StringBuilder, o: float) -> StringBuilder: 58 | (x.buf.append(to_string(o))) 59 | return x 60 | 61 | 62 | def StringBuilder__Append_Z1FBCCD16(x: StringBuilder, o: bool) -> StringBuilder: 63 | (x.buf.append(to_string(o))) 64 | return x 65 | 66 | 67 | def StringBuilder__Append_4E60E31B(x: StringBuilder, o: Any) -> StringBuilder: 68 | (x.buf.append(to_string(o))) 69 | return x 70 | 71 | 72 | def StringBuilder__Append_695F1130(x: StringBuilder, cs: List[str]) -> StringBuilder: 73 | (x.buf.append(''.join(cs))) 74 | return x 75 | 76 | 77 | def StringBuilder__Append_43A65C09(x: StringBuilder, s: StringBuilder) -> StringBuilder: 78 | (x.buf.append(to_string(s))) 79 | return x 80 | 81 | 82 | def StringBuilder__AppendFormat_433E080(x: StringBuilder, fmt: str, o: Any) -> StringBuilder: 83 | (x.buf.append(format(fmt, o))) 84 | return x 85 | 86 | 87 | def StringBuilder__AppendLine(x: StringBuilder) -> StringBuilder: 88 | (x.buf.append("\n")) 89 | return x 90 | 91 | 92 | def StringBuilder__AppendLine_Z721C83C5(x: StringBuilder, s: str) -> StringBuilder: 93 | (x.buf.append(s)) 94 | (x.buf.append("\n")) 95 | return x 96 | 97 | 98 | def StringBuilder__get_Length(x: StringBuilder) -> int: 99 | len_1 : int = 0 100 | for i in range(len(x.buf) - 1, 0 - 1, -1): 101 | len_1 = (len_1 + len(x.buf[i])) or 0 102 | return len_1 103 | 104 | 105 | def StringBuilder__ToString_Z37302880(x: StringBuilder, first_index: int, length: int) -> str: 106 | return substring(to_string(x), first_index, length) 107 | 108 | 109 | def StringBuilder__Clear(x: StringBuilder) -> StringBuilder: 110 | clear(x.buf) 111 | return x 112 | 113 | 114 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/task.py: -------------------------------------------------------------------------------- 1 | from typing import Awaitable, TypeVar, Any 2 | import asyncio 3 | 4 | T = TypeVar("T") 5 | 6 | 7 | async def zero(): 8 | return 9 | 10 | 11 | async def from_result(value: Any): 12 | return value 13 | 14 | 15 | def get_awaiter(value: Awaitable[T]) -> Awaitable[T]: 16 | return value 17 | 18 | 19 | def get_result(value: Awaitable[T]) -> T: 20 | return asyncio.run(value) 21 | 22 | 23 | __all__ = ["get_awaiter", "get_result", "from_result"] 24 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/task_builder.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Any, 3 | Awaitable, 4 | Callable, 5 | Iterable, 6 | Optional, 7 | TypeVar, 8 | overload, 9 | Protocol, 10 | ) 11 | 12 | from .task import from_result, zero 13 | from .util import IDisposable 14 | 15 | T = TypeVar("T") 16 | T_co = TypeVar("T_co", covariant=True) 17 | TD = TypeVar("TD", bound=IDisposable) 18 | U = TypeVar("U") 19 | 20 | 21 | class Delayed(Protocol[T_co]): 22 | def __call__(self, __unit: Optional[None] = None) -> Awaitable[T_co]: 23 | ... 24 | 25 | 26 | class TaskBuilder: 27 | def Bind( 28 | self, computation: Awaitable[T], binder: Callable[[T], Awaitable[U]] 29 | ) -> Awaitable[U]: 30 | async def bind() -> U: 31 | value = await computation 32 | return await binder(value) 33 | 34 | return bind() 35 | 36 | def Combine( 37 | self, computation1: Awaitable[None], computation2: Delayed[T] 38 | ) -> Awaitable[T]: 39 | return self.Bind(computation1, computation2) 40 | 41 | def Delay(self, generator: Callable[[], Awaitable[T]]) -> Delayed[T]: 42 | def deferred(_: Any = None) -> Awaitable[T]: 43 | # print("Delay: deferred: ", generator) 44 | return generator() 45 | 46 | return deferred 47 | 48 | def For( 49 | self, sequence: Iterable[T], body: Callable[[T], Awaitable[U]] 50 | ) -> Awaitable[U]: 51 | done = False 52 | it = iter(sequence) 53 | try: 54 | cur = next(it) 55 | except StopIteration: 56 | done = True 57 | 58 | def delay(): 59 | nonlocal cur, done 60 | res = body(cur) 61 | try: 62 | cur = next(it) 63 | except StopIteration: 64 | done = True 65 | return res 66 | 67 | return self.While(lambda: not done, self.Delay(delay)) 68 | 69 | @overload 70 | def Return(self) -> Awaitable[None]: 71 | ... 72 | 73 | @overload 74 | def Return(self, value: T) -> Awaitable[T]: 75 | ... 76 | 77 | def Return(self, value: Optional[T] = None) -> Awaitable[Optional[T]]: 78 | return from_result(value) 79 | 80 | def ReturnFrom(self, computation: Awaitable[T]) -> Awaitable[T]: 81 | return computation 82 | 83 | def TryFinally( 84 | self, computation: Delayed[T], compensation: Callable[[], None] 85 | ) -> Awaitable[T]: 86 | async def try_finally() -> T: 87 | try: 88 | t = await computation() 89 | finally: 90 | compensation() 91 | return t 92 | 93 | return try_finally() 94 | 95 | def TryWith( 96 | self, computation: Delayed[T], catchHandler: Callable[[Any], Awaitable[T]] 97 | ) -> Awaitable[T]: 98 | async def try_with() -> T: 99 | try: 100 | t = await computation() 101 | except Exception as exn: 102 | t = await catchHandler(exn) 103 | return t 104 | 105 | return try_with() 106 | 107 | def Using(self, resource: TD, binder: Callable[[TD], Awaitable[U]]) -> Awaitable[U]: 108 | return self.TryFinally( 109 | self.Delay(lambda: binder(resource)), lambda: resource.Dispose() 110 | ) 111 | 112 | @overload 113 | def While( 114 | self, guard: Callable[[], bool], computation: Delayed[None] 115 | ) -> Awaitable[None]: 116 | ... 117 | 118 | @overload 119 | def While(self, guard: Callable[[], bool], computation: Delayed[T]) -> Awaitable[T]: # type: ignore 120 | ... 121 | 122 | def While( 123 | self, guard: Callable[[], bool], computation: Delayed[Any] 124 | ) -> Awaitable[Any]: 125 | if guard(): 126 | return self.Bind(computation(), lambda _: self.While(guard, computation)) 127 | else: 128 | return self.Return() 129 | 130 | def Zero(self) -> Awaitable[None]: 131 | return zero() 132 | 133 | def Run(self, computation: Delayed[T]) -> Awaitable[T]: 134 | return computation() 135 | 136 | 137 | task = TaskBuilder 138 | 139 | __all__ = ["task"] 140 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/time_span.py: -------------------------------------------------------------------------------- 1 | from datetime import timedelta 2 | from typing import Optional 3 | 4 | def total_seconds(ts: timedelta) -> float: 5 | return ts.total_seconds() 6 | 7 | def from_milliseconds(msecs: int) -> timedelta: 8 | return timedelta(milliseconds=msecs) 9 | 10 | 11 | def from_ticks(ticks: int) -> timedelta: 12 | return timedelta(microseconds = ticks //10) 13 | 14 | def to_milliseconds(td: timedelta): 15 | return int(td.total_seconds() * 1000) 16 | 17 | def create(d: int = 0, h: Optional[int] = None, m: Optional[int] = None, s: Optional[int] = None, ms: Optional[int] = None) -> timedelta: 18 | if h is None and m is None and s is None and ms is None: 19 | return from_ticks(d) 20 | 21 | return timedelta(days=d, hours=h or 0, minutes=m or 0, seconds=s or 0, milliseconds=ms or 0) 22 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/timer.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from abc import abstractmethod 3 | from typing import Callable 4 | 5 | class ITimer: 6 | @abstractmethod 7 | def Create(self, __arg0: float, __arg1: Callable[[], None]) -> ITimer: 8 | ... 9 | 10 | @abstractmethod 11 | def cancel(self) -> None: 12 | ... 13 | 14 | @property 15 | @abstractmethod 16 | def daemon(self) -> bool: 17 | ... 18 | 19 | @daemon.setter 20 | @abstractmethod 21 | def daemon(self, __arg0: bool) -> None: 22 | ... 23 | 24 | @abstractmethod 25 | def start(self) -> None: 26 | ... 27 | 28 | 29 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_library/uri.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | from urllib.parse import urlparse 3 | from typing import Optional 4 | 5 | 6 | class UriKind(Enum): 7 | RelativeOrAbsolute = 0 8 | Absolute = 1 9 | Relative = 2 10 | 11 | 12 | class Uri: 13 | def __init__(self, uri: str, uri_kind: Optional[int] = None) -> None: 14 | self.res = urlparse(uri) 15 | self.kind = UriKind(uri_kind) if uri_kind else UriKind.Absolute 16 | 17 | @property 18 | def is_absolute_uri(self) -> bool: 19 | return True if self.res.netloc else False 20 | 21 | @property 22 | def scheme(self) -> str: 23 | return self.res.scheme 24 | 25 | @property 26 | def host(self) -> str: 27 | return self.res.hostname or "" 28 | 29 | @property 30 | def absolute_uri(self) -> str: 31 | if self.kind == UriKind.Relative: 32 | raise ValueError("This operation is not supported for a relative URI.") 33 | 34 | return self.res.geturl() 35 | 36 | @property 37 | def absolute_path(self) -> str: 38 | return self.res.path 39 | 40 | @property 41 | def query(self) -> str: 42 | return f"?{self.res.query}" 43 | 44 | @property 45 | def path_and_query(self) -> str: 46 | return f"{self.res.path}?{self.res.query}" 47 | 48 | @property 49 | def fragment(self) -> str: 50 | return f"#{self.res.fragment}" 51 | 52 | def __str__(self) -> str: 53 | return self.res.geturl() 54 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/Fable.Python.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | true 6 | Dag Brattli 7 | Dag Brattli 8 | LICENSE 9 | 3390;$(WarnOn) 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/cognite-sdk/CogniteSdk.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.CogniteSdk 2 | 3 | open Fable.Core 4 | 5 | type ITimeSeries = 6 | abstract plot : start: string * ``end``: string * aggregates: string array * granularity: string -> unit 7 | 8 | type ITimeSeriesApi = 9 | abstract retrieve : id: int64 -> ITimeSeries 10 | abstract list : unit -> ITimeSeries list 11 | 12 | [] 13 | type CogniteClient (?apiKey: string, ?api_subversion: string, ?project: string, ?clientName: string) = 14 | abstract member time_series : ITimeSeriesApi 15 | override this.time_series = nativeOnly 16 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/cognite-sdk/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/cognite-sdk/cognite_sdk.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from abc import abstractmethod 3 | from typing import (List, Any) 4 | from .....fable_library.list import FSharpList 5 | 6 | class ITimeSeries: 7 | @abstractmethod 8 | def plot(self, start: str, end: str, aggregates: List[str], granularity: str) -> None: 9 | ... 10 | 11 | 12 | class ITimeSeriesApi: 13 | @abstractmethod 14 | def list(self) -> FSharpList[ITimeSeries]: 15 | ... 16 | 17 | @abstractmethod 18 | def retrieve(self, id: Any) -> ITimeSeries: 19 | ... 20 | 21 | 22 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/flask/Flask.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Flask 2 | 3 | open Fable.Core 4 | 5 | // fsharplint:disable MemberNames 6 | type RequestBase = 7 | abstract url : string 8 | 9 | type Request = 10 | inherit RequestBase 11 | 12 | type Flask = 13 | abstract route : rule: string -> ((unit -> string) -> Flask) 14 | abstract route : rule: string * methods: string array -> ((unit -> string) -> Flask) 15 | 16 | type FlaskStatic = 17 | [] 18 | abstract Create : name: string * static_url_path: string -> Flask 19 | 20 | [] 21 | let Flask : FlaskStatic = nativeOnly 22 | 23 | type IExports = 24 | abstract render_template : template_name_or_list: string -> string 25 | abstract render_template : template_name_or_list: string seq -> string 26 | abstract request : Request 27 | 28 | [] 29 | abstract url_for : route : string * filename: string -> string 30 | 31 | [] 32 | let flask: IExports = nativeOnly 33 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/flask/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/flask/flask.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from abc import abstractmethod 3 | 4 | class RequestBase: 5 | @property 6 | @abstractmethod 7 | def url(self) -> str: 8 | ... 9 | 10 | 11 | class Request(RequestBase): 12 | pass 13 | 14 | class Flask: 15 | pass 16 | 17 | class FlaskStatic: 18 | @abstractmethod 19 | def Create(self, name: str, static_url_path: str) -> Flask: 20 | ... 21 | 22 | 23 | class IExports: 24 | @property 25 | @abstractmethod 26 | def request(self) -> Request: 27 | ... 28 | 29 | @abstractmethod 30 | def url_for(self, route: str, filename: str) -> str: 31 | ... 32 | 33 | 34 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/jupyter/IPyWidgets.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.IPyWidgets 2 | 3 | open Fable.Core 4 | 5 | 6 | type IWidget = 7 | abstract close : unit -> unit 8 | 9 | type IIntSlider = 10 | inherit IWidget 11 | 12 | abstract value : int 13 | abstract min : int 14 | abstract max : int 15 | 16 | type IFloatSlider = 17 | inherit IWidget 18 | 19 | abstract value : float 20 | abstract min : float 21 | abstract max : float 22 | 23 | type IExports = 24 | [] 25 | abstract interact<'T1, 'T2> : fn : ('T1 -> 'T2) * x: 'T1 -> 'T2 26 | [] 27 | abstract interact<'T1, 'T2, 'T3> : fn : ('T1*'T2 -> 'T3) * x: 'T1 * y: 'T2 -> 'T3 28 | 29 | abstract IntSlider : unit -> IIntSlider 30 | abstract IntSlider : value: int -> IIntSlider 31 | abstract IntSlider : value: int * min: int * max: int * step: int * description: string -> IIntSlider 32 | 33 | abstract FloatSlider : unit -> IFloatSlider 34 | abstract FloatSlider : value: float -> IFloatSlider 35 | abstract FloatSlider : value: float * min: int * max: int * step: int * description: string -> IFloatSlider 36 | 37 | [] 38 | let widgets : IExports = nativeOnly 39 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/jupyter/IPython.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.IPython 2 | 3 | open Fable.Core 4 | 5 | type IDisplay = 6 | abstract display : value: obj -> unit 7 | abstract Code : data: string -> unit 8 | [] 9 | abstract Code : data: string * language: string -> unit 10 | [] 11 | abstract Markdown : data: string -> unit 12 | 13 | [] 14 | let display : IDisplay = nativeOnly 15 | 16 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/jupyter/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/jupyter/ipy_widgets.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | 3 | class IWidget: 4 | @abstractmethod 5 | def close(self) -> None: 6 | ... 7 | 8 | 9 | class IIntSlider(IWidget): 10 | @property 11 | @abstractmethod 12 | def max(self) -> int: 13 | ... 14 | 15 | @property 16 | @abstractmethod 17 | def min(self) -> int: 18 | ... 19 | 20 | @property 21 | @abstractmethod 22 | def value(self) -> int: 23 | ... 24 | 25 | 26 | class IFloatSlider(IWidget): 27 | @property 28 | @abstractmethod 29 | def max(self) -> float: 30 | ... 31 | 32 | @property 33 | @abstractmethod 34 | def min(self) -> float: 35 | ... 36 | 37 | @property 38 | @abstractmethod 39 | def value(self) -> float: 40 | ... 41 | 42 | 43 | class IExports: 44 | pass 45 | 46 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/jupyter/ipython.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import Any 3 | 4 | class IDisplay: 5 | @abstractmethod 6 | def Markdown(self, data: str) -> None: 7 | ... 8 | 9 | @abstractmethod 10 | def display(self, value: Any) -> None: 11 | ... 12 | 13 | 14 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/microbit/Speach.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Speach 2 | 3 | open Fable.Core 4 | 5 | type ISpeach = 6 | abstract say : text: string -> unit 7 | 8 | [] 9 | let speach: ISpeach = nativeOnly 10 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/microbit/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/microbit/micro_bit.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | 3 | class IDisplay: 4 | @abstractmethod 5 | def clear(self) -> None: 6 | ... 7 | 8 | @abstractmethod 9 | def is_on(self) -> bool: 10 | ... 11 | 12 | @abstractmethod 13 | def off(self) -> None: 14 | ... 15 | 16 | @abstractmethod 17 | def on(self) -> None: 18 | ... 19 | 20 | 21 | class IButton: 22 | @abstractmethod 23 | def presses(self) -> int: 24 | ... 25 | 26 | @abstractmethod 27 | def is_pressed(self) -> bool: 28 | ... 29 | 30 | @abstractmethod 31 | def was_pressed(self) -> bool: 32 | ... 33 | 34 | 35 | class ICompass: 36 | @abstractmethod 37 | def calibrate(self) -> None: 38 | ... 39 | 40 | @abstractmethod 41 | def heading(self) -> int: 42 | ... 43 | 44 | 45 | class IAccelerometer: 46 | @abstractmethod 47 | def x(self) -> int: 48 | ... 49 | 50 | @abstractmethod 51 | def y(self) -> int: 52 | ... 53 | 54 | @abstractmethod 55 | def z(self) -> int: 56 | ... 57 | 58 | 59 | class IPinLogo: 60 | @abstractmethod 61 | def is_touched(self) -> bool: 62 | ... 63 | 64 | 65 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/microbit/speach.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | 3 | class ISpeach: 4 | @abstractmethod 5 | def say(self, text: str) -> None: 6 | ... 7 | 8 | 9 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/pyproject.toml: -------------------------------------------------------------------------------- 1 | 2 | [tool.poetry] 3 | name = "fable-python" 4 | version = "0.1.0" 5 | description = "Python bindings for Fable" 6 | authors = ["Dag Brattli "] 7 | license = "MIT" 8 | 9 | [tool.poetry.dependencies] 10 | python = "^3.8" 11 | fable-library = "^0.3.0" 12 | 13 | [tool.poetry.dev-dependencies] 14 | 15 | [tool.fable] 16 | package-dir = "fable-python/fable_python" 17 | 18 | [build-system] 19 | requires = ["poetry-core>=1.0.0"] 20 | build-backend = "poetry.core.masonry.api" 21 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Ast.fs: -------------------------------------------------------------------------------- 1 | module rec Fable.Python.Ast 2 | 3 | open Fable.Core 4 | 5 | // fsharplint:disable MemberNames,InterfaceNames 6 | 7 | type _identifier = string 8 | 9 | 10 | type AST = 11 | abstract foo : int 12 | 13 | type ``mod`` = 14 | inherit AST 15 | 16 | type expr = 17 | inherit AST 18 | 19 | type Module = 20 | inherit ``mod`` 21 | abstract body : stmt array 22 | 23 | type Expression = 24 | inherit ``mod`` 25 | abstract body : expr 26 | 27 | type stmt = 28 | inherit AST 29 | 30 | 31 | type FunctionDef = 32 | inherit stmt 33 | 34 | abstract name : _identifier 35 | abstract args : arguments 36 | abstract body : stmt array 37 | abstract decorator_list : expr array 38 | abstract returns : expr option 39 | 40 | type ClassDef = 41 | inherit stmt 42 | abstract name : _identifier 43 | abstract bases : expr array 44 | abstract keywords : keyword array 45 | abstract body : stmt array 46 | abstract decorator_list : expr array 47 | 48 | type Return = 49 | inherit stmt 50 | abstract value : expr option 51 | 52 | type Delete = 53 | inherit stmt 54 | abstract targets : expr array 55 | 56 | type Assign = 57 | inherit stmt 58 | abstract targets : expr array 59 | abstract value : expr 60 | 61 | type Import = 62 | inherit stmt 63 | abstract names : alias array 64 | 65 | type ImportFrom = 66 | inherit stmt 67 | abstract ``module`` : _identifier option 68 | abstract names : alias array 69 | abstract level : int 70 | 71 | type If = 72 | inherit stmt 73 | abstract test : expr 74 | abstract body : stmt array 75 | abstract orelse : stmt array 76 | 77 | type arguments = 78 | inherit AST 79 | 80 | abstract posonlyargs : arg array 81 | abstract args : arg array 82 | abstract vararg : arg option 83 | abstract kwonlyargs : arg array 84 | abstract kw_defaults : expr option list 85 | abstract kwarg : arg option 86 | abstract defaults : expr array 87 | 88 | type arg = 89 | inherit AST 90 | abstract arg : _identifier 91 | abstract annotation : expr option 92 | 93 | type keyword = 94 | inherit AST 95 | abstract arg : _identifier option 96 | abstract value : expr 97 | 98 | type alias = 99 | inherit AST 100 | abstract name : _identifier 101 | abstract asname : _identifier option 102 | 103 | 104 | [] 105 | type Mode = 106 | | Exec 107 | | [] FuncMode 108 | 109 | type IExports = 110 | /// Parse the source into an AST node 111 | abstract parse : string -> AST 112 | abstract parse : string * filename: string -> AST 113 | abstract parse : string * filename: string * mode: Mode -> AST 114 | abstract unparse : astObj: AST -> string 115 | abstract walk : node: AST -> AST array 116 | /// Return a formatted dump of the tree in node. 117 | abstract dump : node: AST -> string 118 | /// Return a formatted dump of the tree in node. 119 | abstract dump : node: AST * annotate_fields: bool -> string 120 | /// Return a formatted dump of the tree in node. 121 | abstract dump : node: AST * annotate_fields: bool * include_attributes: bool -> string 122 | 123 | [] 124 | let ast: IExports = nativeOnly 125 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Base64.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Base64 2 | 3 | open Fable.Core 4 | 5 | // fsharplint:disable MemberNames 6 | 7 | type IExports = 8 | abstract b64encode : byte[] -> byte[] 9 | abstract b64encode : s : byte[] * altchars: byte[] -> byte[] 10 | 11 | abstract b64decode : byte[] -> byte[] 12 | abstract b64decode : string -> byte[] 13 | abstract b64decode : s: byte[] * altchars : byte[] -> byte[] 14 | abstract b64decode : s: string * altchars : byte[] -> byte[] 15 | abstract b64decode : s: byte[] * altchars : byte[] * validate: bool -> byte[] 16 | abstract b64decode : s: string * altchars : byte[] * validate: bool -> byte[] 17 | abstract b64decode : s: byte[] * validate: bool -> byte[] 18 | abstract b64decode : s: string * validate: bool -> byte[] 19 | 20 | abstract standard_b64encode : byte[] -> byte[] 21 | abstract standard_b64decode : string -> byte[] 22 | abstract standard_b64decode : byte[] -> byte[] 23 | abstract urlsafe_b64encode : byte[] -> byte[] 24 | abstract urlsafe_b64decode : string -> byte[] 25 | abstract urlsafe_b64decode : byte[] -> byte[] 26 | abstract b32encode : byte[] -> byte[] 27 | abstract b16encode : byte[] -> byte 28 | 29 | /// Base16, Base32, Base64, Base85 Data Encodings 30 | [] 31 | let base64: IExports = nativeOnly 32 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Builtins.fs: -------------------------------------------------------------------------------- 1 | /// Type bindings for Python builtins: https://docs.python.org/3/library/functions.html#built-in-funcs 2 | module Fable.Python.Builtins 3 | 4 | open System.Collections.Generic 5 | open Fable.Core 6 | 7 | // fsharplint:disable MemberNames,InterfaceNames 8 | 9 | type TextIOBase = 10 | abstract read : unit -> string 11 | abstract read : __size: int -> string 12 | 13 | type TextIOWrapper = 14 | inherit TextIOBase 15 | 16 | [] 17 | type OpenTextModeUpdating = 18 | | [] ReadUpdate 19 | | [] UpdateRead 20 | | [] ReadTextUpdate 21 | | [] ReadUpdateText 22 | | [] UpdateReadText 23 | | [] TextReadUpdate 24 | | [] TextUpdateRead 25 | | [] UpdateTextRead 26 | | [] WriteUpdate 27 | | [] UpdateWrite 28 | | [] WriteTextUpdate 29 | | [] WriteUpdateText 30 | | [] UpdateWriteText 31 | | [] TextWriteUpdate 32 | | [] TextUpdateWrite 33 | | [] UpdateTextWrite 34 | | [] AppendUpdate 35 | | [] UpdateAppend 36 | | [] AppendTextUpdate 37 | | [] AppendUpdateText 38 | | [] UpdateAppendText 39 | | [] TextAppendUpdate 40 | | [] TextUpdateAppend 41 | | [] UpdateTextAppend 42 | | [] CreateUpdate 43 | | [] UpdateCreate 44 | | [] CreateTextUpdate 45 | | [] CreateUpdateText 46 | | [] UpdateCreateText 47 | | [] TextCreateUpdate 48 | | [] TextUpdateCreate 49 | | [] UpdateTextCreate 50 | 51 | [] 52 | type OpenTextModeReading = 53 | | [] Read 54 | | [] ReadText 55 | | [] TextRead 56 | 57 | [] 58 | type OpenTextModeWriting = 59 | | [] Write 60 | | [] WriteText 61 | | [] TextWrite 62 | | [] Append 63 | | [] AppendText 64 | | [] TextAppend 65 | | [] Create 66 | | [] CreateText 67 | | [] TextCreate 68 | 69 | [] 70 | type OpenTextMode = 71 | | OpenTextModeUpdating 72 | | OpenTextModeWriting 73 | | OpenTextModeReading 74 | 75 | 76 | [] 77 | type _OpenFile = 78 | | StrOrBytesPath of string 79 | | FileDescriptor of int 80 | 81 | type IExports = 82 | /// Return the absolute value of the argument. 83 | abstract abs : int -> int 84 | /// Return the absolute value of the argument. 85 | abstract abs : float -> float 86 | /// Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff. 87 | abstract chr : int -> char 88 | /// Return the names in the current scope. 89 | abstract dir : unit -> string list 90 | /// Return an alphabetized list of names comprising (some of) the 91 | /// attributes of the given object, and of attributes reachable from 92 | /// it 93 | abstract dir : obj -> string list 94 | /// Return the identity of an object. 95 | abstract id : obj -> int 96 | ///Return the length (the number of items) of an object. The argument may 97 | ///be a sequence (such as a string, bytes, tuple, list, or range) or a 98 | ///collection (such as a dictionary, set, or frozen set). 99 | abstract len : obj -> int 100 | /// Make an iterator that computes the function using arguments from 101 | /// the iterable. Stops when iterable is exhausted. 102 | abstract map : ('T1 -> 'T2) * IEnumerable<'T1> -> IEnumerable<'T2> 103 | /// Make an iterator that computes the function using arguments from each 104 | /// of the iterables. Stops when the shortest iterable is exhausted. 105 | abstract map : ('T1 * 'T2 -> 'T3) * IEnumerable<'T1> * IEnumerable<'T2> -> IEnumerable<'T3> 106 | /// Make an iterator that computes the function using arguments from each 107 | /// of the iterables. Stops when the shortest iterable is exhausted. 108 | abstract map : ('T1 * 'T2 * 'T3 -> 'T4) * IEnumerable<'T1> * IEnumerable<'T2> * IEnumerable<'T3> -> IEnumerable<'T4> 109 | /// Return the Unicode code point for a one-character string. 110 | abstract ord : char -> int 111 | /// Object to string 112 | abstract str : obj -> string 113 | /// Object to int 114 | abstract int : obj -> int 115 | /// Object to float 116 | abstract float : obj -> float 117 | abstract print : obj: obj -> unit 118 | abstract read : file: _OpenFile -> TextIOWrapper 119 | abstract read : file: _OpenFile * mode: OpenTextMode -> TextIOWrapper 120 | abstract read : file: _OpenFile * mode: OpenTextMode * buffering: int -> TextIOWrapper 121 | abstract read : file: _OpenFile * mode: OpenTextMode * buffering: int * encoding: string -> TextIOWrapper 122 | 123 | abstract read : 124 | file: _OpenFile * mode: OpenTextMode * buffering: int * encoding: string * errors: string -> TextIOWrapper 125 | 126 | abstract read : 127 | file: _OpenFile * mode: OpenTextMode * buffering: int * encoding: string * errors: string * newline: string -> 128 | TextIOWrapper 129 | 130 | [] 131 | let builtins: IExports = nativeOnly 132 | 133 | // NOTE: Below we can add builtins that don't require overloads, and do not 134 | // conflict with common F# or .NET functions. If they do we keep them in 135 | // `IExports` above. 136 | 137 | [] 138 | let __name__: string = nativeOnly 139 | 140 | /// Python print function. Takes a single argument, so can be used with e.g string interpolation. 141 | let print obj = builtins.print obj 142 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Html.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Html 2 | 3 | open Fable.Core 4 | 5 | // fsharplint:disable MemberNames 6 | 7 | type IExports = 8 | abstract escape : string -> string 9 | abstract escape : string * bool -> string 10 | abstract unescape : string -> string 11 | 12 | /// Miscellaneous operating system interfaces 13 | [] 14 | let html: IExports = nativeOnly 15 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Json.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Json 2 | 3 | open Fable.Core 4 | 5 | // fsharplint:disable MemberNames 6 | 7 | type IExports = 8 | abstract dumps : obj: obj -> string 9 | abstract loads : string -> obj 10 | 11 | [] 12 | let json: IExports = nativeOnly 13 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Math.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Math 2 | 3 | open System 4 | open Fable.Core 5 | 6 | // fsharplint:disable MemberNames 7 | 8 | type IExports = 9 | abstract ceil : int -> int 10 | abstract ceil : float -> int 11 | abstract comb : int -> int -> int 12 | abstract copysign : float -> int -> float 13 | abstract fabs : float -> float 14 | abstract factorial : float -> float 15 | abstract floor : int -> int 16 | abstract floor : float -> int 17 | abstract fmod : int -> int -> int 18 | 19 | abstract gcd : [] ints: int[] -> int 20 | abstract isfinite : float -> bool 21 | abstract isfinite : int -> bool 22 | abstract isinf : float -> bool 23 | abstract isinf : int -> bool 24 | abstract isnan : float -> bool 25 | abstract isnan : int -> bool 26 | abstract lcm : [] ints: int[] -> int 27 | 28 | abstract exp : float -> float 29 | abstract expm1 : float -> float 30 | abstract log : float -> float 31 | abstract log1p : float -> float 32 | abstract log2 : float -> float 33 | abstract log10 : float -> float 34 | abstract pow : float -> float -> float 35 | 36 | abstract acos : float -> float 37 | abstract asin : float -> float 38 | abstract atan : float -> float 39 | abstract atan2 : float -> float -> float 40 | abstract cos : float -> float 41 | abstract dist : float -> float -> float 42 | abstract sin : float -> float 43 | abstract tan : float -> float 44 | 45 | [] 46 | let math: IExports = nativeOnly -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Os.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Os 2 | 3 | open System.Collections.Generic 4 | open Fable.Core 5 | 6 | // fsharplint:disable MemberNames 7 | 8 | type IExports = 9 | abstract chdir : string -> unit 10 | abstract chroot : string -> unit 11 | abstract close : fd: int -> unit 12 | abstract environ : Dictionary 13 | abstract getcwd : unit -> string 14 | abstract getenv : key: string -> string option 15 | abstract getenv : key: string * ``default``: string -> string 16 | abstract kill : pid: int * ``sig``: int -> unit 17 | abstract putenv : key: string * value: string -> unit 18 | 19 | 20 | /// Miscellaneous operating system interfaces 21 | [] 22 | let os: IExports = nativeOnly 23 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Queue.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Queue 2 | 3 | open Fable.Core 4 | 5 | // fsharplint:disable MemberNames 6 | 7 | [] 8 | type Queue<'T> () = 9 | /// Return the approximate size of the queue. Note, qsize() > 0 doesn’t guarantee that a subsequent get() will not 10 | /// block, nor will qsize() < maxsize guarantee that put() will not block. 11 | member x.qsize() : int = nativeOnly 12 | /// Return True if the queue is empty, False otherwise. If empty() returns True it doesn’t guarantee that a 13 | /// subsequent call to put() will not block. Similarly, if empty() returns False it doesn’t guarantee that a 14 | /// subsequent call to get() will not block. 15 | member x.empty() : bool = nativeOnly 16 | /// Return True if the queue is full, False otherwise. If full() returns True it doesn’t guarantee that a subsequent 17 | /// call to get() will not block. Similarly, if full() returns False it doesn’t guarantee that a subsequent call to 18 | /// put() will not block. 19 | member x.full() : bool = nativeOnly 20 | /// Put item into the queue. If optional args block is true and timeout is None (the default), block if necessary 21 | /// until a free slot is available. If timeout is a positive number, it blocks at most timeout seconds and raises 22 | /// the Full exception if no free slot was available within that time. Otherwise (block is false), put an item on 23 | /// the queue if a free slot is immediately available, else raise the Full exception (timeout is ignored in that 24 | /// case). 25 | member x.put(item: 'T, ?block: bool, ?timeout: float) : unit = nativeOnly 26 | /// Remove and return an item from the queue. If optional args block is true and timeout is None (the default), 27 | /// block if necessary until an item is available. If timeout is a positive number, it blocks at most timeout 28 | /// seconds and raises the Empty exception if no item was available within that time. Otherwise (block is false), 29 | /// return an item if one is immediately available, else raise the Empty exception (timeout is ignored in that 30 | /// case). 31 | /// 32 | /// Prior to 3.0 on POSIX systems, and for all versions on Windows, if block is true and timeout is None, this 33 | /// operation goes into an uninterruptible wait on an underlying lock. This means that no exceptions can occur, and 34 | /// in particular a SIGINT will not trigger a KeyboardInterrupt. 35 | member x.get(?block: bool, ?timeout: float) : 'T = nativeOnly 36 | /// Blocks until all items in the queue have been gotten and processed. 37 | /// 38 | /// The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a 39 | /// consumer thread calls task_done() to indicate that the item was retrieved and all work on it is complete. When 40 | /// the count of unfinished tasks drops to zero, join() unblocks. 41 | member x.join() : unit = nativeOnly 42 | 43 | member x.task_done() : unit = nativeOnly 44 | 45 | [] 46 | type PriorityQueue<'T> () = 47 | inherit Queue<'T> () 48 | 49 | [] 50 | type LifoQueue<'T> () = 51 | inherit Queue<'T> () 52 | 53 | [] 54 | type SimpleQueue<'T> () = 55 | /// Return the approximate size of the queue. Note, qsize() > 0 doesn’t guarantee that a subsequent get() will not 56 | /// block, nor will qsize() < maxsize guarantee that put() will not block. 57 | member x.qsize() : int = nativeOnly 58 | /// Return True if the queue is empty, False otherwise. If empty() returns True it doesn’t guarantee that a 59 | /// subsequent call to put() will not block. Similarly, if empty() returns False it doesn’t guarantee that a 60 | /// subsequent call to get() will not block. 61 | member x.empty() : bool = nativeOnly 62 | /// Return True if the queue is full, False otherwise. If full() returns True it doesn’t guarantee that a subsequent 63 | /// call to get() will not block. Similarly, if full() returns False it doesn’t guarantee that a subsequent call to 64 | /// put() will not block. 65 | member x.put(item: 'T, ?block: bool, ?timeout: float) : unit = nativeOnly 66 | /// Remove and return an item from the queue. If optional args block is true and timeout is None (the default), 67 | /// block if necessary until an item is available. If timeout is a positive number, it blocks at most timeout 68 | /// seconds and raises the Empty exception if no item was available within that time. Otherwise (block is false), 69 | /// return an item if one is immediately available, else raise the Empty exception (timeout is ignored in that 70 | /// case). 71 | /// 72 | /// Prior to 3.0 on POSIX systems, and for all versions on Windows, if block is true and timeout is None, this 73 | /// operation goes into an uninterruptible wait on an underlying lock. This means that no exceptions can occur, and 74 | /// in particular a SIGINT will not trigger a KeyboardInterrupt. 75 | member x.get(?block: bool, ?timeout: float) : 'T = nativeOnly 76 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Sys.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Sys 2 | 3 | open Fable.Core 4 | 5 | // fsharplint:disable MemberNames 6 | 7 | [] 8 | type ByteOrder = 9 | | Little 10 | | Big 11 | 12 | type VersionInfo = 13 | abstract major : int 14 | abstract minor: int 15 | abstract micro: int 16 | abstract releaselevel: string 17 | abstract serial: int 18 | 19 | type IExports = 20 | abstract argv : string array 21 | abstract byteorder: ByteOrder 22 | abstract hexversion: int 23 | abstract maxsize: int 24 | abstract maxunicode: int 25 | abstract path : string array 26 | abstract platform : string 27 | abstract prefix: string 28 | abstract version: string 29 | abstract version_info: VersionInfo 30 | 31 | /// System-specific parameters and functions 32 | [] 33 | let sys: IExports = nativeOnly 34 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/Time.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.Time 2 | 3 | open Fable.Core 4 | 5 | // fsharplint:disable MemberNames 6 | 7 | type IExports = 8 | abstract altzone : int 9 | abstract ctime : unit -> string 10 | abstract ctime : float -> string 11 | abstract daylight : int 12 | abstract monotonic : unit -> float 13 | abstract perf_counter : unit -> float 14 | abstract process_time : unit -> float 15 | abstract sleep : secs: float -> unit 16 | abstract time : unit -> float 17 | abstract timezone : int 18 | abstract tzname : string * string 19 | 20 | /// Time access and conversions 21 | [] 22 | let time: IExports = nativeOnly 23 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/TkInter.fs: -------------------------------------------------------------------------------- 1 | module Fable.Python.TkInter 2 | 3 | open Fable.Core 4 | 5 | type Event = 6 | abstract member x : int 7 | abstract member y : int 8 | 9 | type Misc = 10 | abstract member bind : sequence: string * func: (Event -> unit) -> string option 11 | 12 | type Wm = 13 | abstract member title : unit -> string 14 | abstract member title : string: string -> unit 15 | 16 | [] 17 | type Tk (screenName: string option) = 18 | interface Wm with 19 | member _.title(string: string) = nativeOnly 20 | member _.title() = nativeOnly 21 | 22 | interface Misc with 23 | member _.bind(sequence: string, func: (Event -> unit)) = nativeOnly 24 | 25 | new () = Tk(None) 26 | 27 | member _.title(string: string) = nativeOnly 28 | member _.title() = nativeOnly 29 | 30 | member _.update() = nativeOnly 31 | member _.mainloop() = nativeOnly 32 | member _.after(msecs: int, callback: unit -> unit) = nativeOnly 33 | 34 | [] 35 | type Frame (master: Misc) = 36 | [] 37 | [] 38 | new (master: Tk, width: int, height: int, bg: string) = Frame(master :> Misc) 39 | 40 | member _.bind(sequence: string, func: (Event -> unit)) : string option = nativeOnly 41 | member _.pack() : unit = nativeOnly 42 | 43 | [] 44 | type Label (master: Frame) = 45 | [] 46 | [] 47 | new (master: Frame, text: string, fg: string, bg: string) = Label(master) 48 | 49 | [] 50 | member _.place(x: int, y: int) = nativeOnly 51 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/ast.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from abc import abstractmethod 3 | from typing import (List, Optional) 4 | from .....fable_library.list import FSharpList 5 | 6 | class AST: 7 | @property 8 | @abstractmethod 9 | def foo(self) -> int: 10 | ... 11 | 12 | 13 | class mod(AST): 14 | pass 15 | 16 | class expr(AST): 17 | pass 18 | 19 | class Module(mod, AST): 20 | @property 21 | @abstractmethod 22 | def body(self) -> List[stmt]: 23 | ... 24 | 25 | 26 | class Expression(mod, AST): 27 | @property 28 | @abstractmethod 29 | def body(self) -> expr: 30 | ... 31 | 32 | 33 | class stmt(AST): 34 | pass 35 | 36 | class FunctionDef(stmt, AST): 37 | @property 38 | @abstractmethod 39 | def args(self) -> arguments: 40 | ... 41 | 42 | @property 43 | @abstractmethod 44 | def body(self) -> List[stmt]: 45 | ... 46 | 47 | @property 48 | @abstractmethod 49 | def decorator_list(self) -> List[expr]: 50 | ... 51 | 52 | @property 53 | @abstractmethod 54 | def name(self) -> str: 55 | ... 56 | 57 | @property 58 | @abstractmethod 59 | def returns(self) -> Optional[expr]: 60 | ... 61 | 62 | 63 | class ClassDef(stmt, AST): 64 | @property 65 | @abstractmethod 66 | def bases(self) -> List[expr]: 67 | ... 68 | 69 | @property 70 | @abstractmethod 71 | def body(self) -> List[stmt]: 72 | ... 73 | 74 | @property 75 | @abstractmethod 76 | def decorator_list(self) -> List[expr]: 77 | ... 78 | 79 | @property 80 | @abstractmethod 81 | def keywords(self) -> List[keyword]: 82 | ... 83 | 84 | @property 85 | @abstractmethod 86 | def name(self) -> str: 87 | ... 88 | 89 | 90 | class Return(stmt, AST): 91 | @property 92 | @abstractmethod 93 | def value(self) -> Optional[expr]: 94 | ... 95 | 96 | 97 | class Delete(stmt, AST): 98 | @property 99 | @abstractmethod 100 | def targets(self) -> List[expr]: 101 | ... 102 | 103 | 104 | class Assign(stmt, AST): 105 | @property 106 | @abstractmethod 107 | def targets(self) -> List[expr]: 108 | ... 109 | 110 | @property 111 | @abstractmethod 112 | def value(self) -> expr: 113 | ... 114 | 115 | 116 | class Import(stmt, AST): 117 | @property 118 | @abstractmethod 119 | def names(self) -> List[alias]: 120 | ... 121 | 122 | 123 | class ImportFrom(stmt, AST): 124 | @property 125 | @abstractmethod 126 | def level(self) -> int: 127 | ... 128 | 129 | @property 130 | @abstractmethod 131 | def module(self) -> Optional[str]: 132 | ... 133 | 134 | @property 135 | @abstractmethod 136 | def names(self) -> List[alias]: 137 | ... 138 | 139 | 140 | class If(stmt, AST): 141 | @property 142 | @abstractmethod 143 | def body(self) -> List[stmt]: 144 | ... 145 | 146 | @property 147 | @abstractmethod 148 | def orelse(self) -> List[stmt]: 149 | ... 150 | 151 | @property 152 | @abstractmethod 153 | def test(self) -> expr: 154 | ... 155 | 156 | 157 | class arguments(AST): 158 | @property 159 | @abstractmethod 160 | def args(self) -> List[arg]: 161 | ... 162 | 163 | @property 164 | @abstractmethod 165 | def defaults(self) -> List[expr]: 166 | ... 167 | 168 | @property 169 | @abstractmethod 170 | def kw_defaults(self) -> FSharpList[Optional[expr]]: 171 | ... 172 | 173 | @property 174 | @abstractmethod 175 | def kwarg(self) -> Optional[arg]: 176 | ... 177 | 178 | @property 179 | @abstractmethod 180 | def kwonlyargs(self) -> List[arg]: 181 | ... 182 | 183 | @property 184 | @abstractmethod 185 | def posonlyargs(self) -> List[arg]: 186 | ... 187 | 188 | @property 189 | @abstractmethod 190 | def vararg(self) -> Optional[arg]: 191 | ... 192 | 193 | 194 | class arg(AST): 195 | @property 196 | @abstractmethod 197 | def annotation(self) -> Optional[expr]: 198 | ... 199 | 200 | @property 201 | @abstractmethod 202 | def arg(self) -> str: 203 | ... 204 | 205 | 206 | class keyword(AST): 207 | @property 208 | @abstractmethod 209 | def arg(self) -> Optional[str]: 210 | ... 211 | 212 | @property 213 | @abstractmethod 214 | def value(self) -> expr: 215 | ... 216 | 217 | 218 | class alias(AST): 219 | @property 220 | @abstractmethod 221 | def asname(self) -> Optional[str]: 222 | ... 223 | 224 | @property 225 | @abstractmethod 226 | def name(self) -> str: 227 | ... 228 | 229 | 230 | class IExports: 231 | @abstractmethod 232 | def unparse(self, astObj: AST) -> str: 233 | ... 234 | 235 | @abstractmethod 236 | def walk(self, node: AST) -> List[AST]: 237 | ... 238 | 239 | 240 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/base64.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import ByteString 3 | 4 | class IExports: 5 | @abstractmethod 6 | def b16encode(self, __arg0: ByteString) -> int: 7 | ... 8 | 9 | @abstractmethod 10 | def b32encode(self, __arg0: ByteString) -> ByteString: 11 | ... 12 | 13 | @abstractmethod 14 | def standard_b64encode(self, __arg0: ByteString) -> ByteString: 15 | ... 16 | 17 | @abstractmethod 18 | def urlsafe_b64encode(self, __arg0: ByteString) -> ByteString: 19 | ... 20 | 21 | 22 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/builtins.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | import builtins 3 | from typing import (Any, TypeVar) 4 | 5 | a_ = TypeVar("a_") 6 | 7 | class TextIOBase: 8 | pass 9 | 10 | class TextIOWrapper(TextIOBase): 11 | pass 12 | 13 | class IExports: 14 | @abstractmethod 15 | def chr(self, __arg0: int) -> str: 16 | ... 17 | 18 | @abstractmethod 19 | def float(self, __arg0: Any) -> float: 20 | ... 21 | 22 | @abstractmethod 23 | def id(self, __arg0: Any) -> int: 24 | ... 25 | 26 | @abstractmethod 27 | def int(self, __arg0: Any) -> int: 28 | ... 29 | 30 | @abstractmethod 31 | def len(self, __arg0: Any) -> int: 32 | ... 33 | 34 | @abstractmethod 35 | def ord(self, __arg0: str) -> int: 36 | ... 37 | 38 | @abstractmethod 39 | def print(self, obj: Any) -> None: 40 | ... 41 | 42 | @abstractmethod 43 | def str(self, __arg0: Any) -> str: 44 | ... 45 | 46 | 47 | def print(obj: Any=None) -> None: 48 | builtins.print(obj) 49 | 50 | 51 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/html.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | 3 | class IExports: 4 | @abstractmethod 5 | def unescape(self, __arg0: str) -> str: 6 | ... 7 | 8 | 9 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/json.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import Any 3 | 4 | class IExports: 5 | @abstractmethod 6 | def dumps(self, obj: Any) -> str: 7 | ... 8 | 9 | @abstractmethod 10 | def loads(self, __arg0: str) -> Any: 11 | ... 12 | 13 | 14 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/math.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import MutableSequence 3 | 4 | class IExports: 5 | @abstractmethod 6 | def acos(self, __arg0: float) -> float: 7 | ... 8 | 9 | @abstractmethod 10 | def asin(self, __arg0: float) -> float: 11 | ... 12 | 13 | @abstractmethod 14 | def atan(self, __arg0: float) -> float: 15 | ... 16 | 17 | @abstractmethod 18 | def atan2(self, __arg0: float, __arg1: float) -> float: 19 | ... 20 | 21 | @abstractmethod 22 | def comb(self, __arg0: int, __arg1: int) -> int: 23 | ... 24 | 25 | @abstractmethod 26 | def copysign(self, __arg0: float, __arg1: int) -> float: 27 | ... 28 | 29 | @abstractmethod 30 | def cos(self, __arg0: float) -> float: 31 | ... 32 | 33 | @abstractmethod 34 | def dist(self, __arg0: float, __arg1: float) -> float: 35 | ... 36 | 37 | @abstractmethod 38 | def exp(self, __arg0: float) -> float: 39 | ... 40 | 41 | @abstractmethod 42 | def expm1(self, __arg0: float) -> float: 43 | ... 44 | 45 | @abstractmethod 46 | def fabs(self, __arg0: float) -> float: 47 | ... 48 | 49 | @abstractmethod 50 | def factorial(self, __arg0: float) -> float: 51 | ... 52 | 53 | @abstractmethod 54 | def fmod(self, __arg0: int, __arg1: int) -> int: 55 | ... 56 | 57 | @abstractmethod 58 | def gcd(self, ints: MutableSequence[int]) -> int: 59 | ... 60 | 61 | @abstractmethod 62 | def lcm(self, ints: MutableSequence[int]) -> int: 63 | ... 64 | 65 | @abstractmethod 66 | def log(self, __arg0: float) -> float: 67 | ... 68 | 69 | @abstractmethod 70 | def log10(self, __arg0: float) -> float: 71 | ... 72 | 73 | @abstractmethod 74 | def log1p(self, __arg0: float) -> float: 75 | ... 76 | 77 | @abstractmethod 78 | def log2(self, __arg0: float) -> float: 79 | ... 80 | 81 | @abstractmethod 82 | def pow(self, __arg0: float, __arg1: float) -> float: 83 | ... 84 | 85 | @abstractmethod 86 | def sin(self, __arg0: float) -> float: 87 | ... 88 | 89 | @abstractmethod 90 | def tan(self, __arg0: float) -> float: 91 | ... 92 | 93 | 94 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/os.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import Any 3 | 4 | class IExports: 5 | @abstractmethod 6 | def chdir(self, __arg0: str) -> None: 7 | ... 8 | 9 | @abstractmethod 10 | def chroot(self, __arg0: str) -> None: 11 | ... 12 | 13 | @abstractmethod 14 | def close(self, fd: int) -> None: 15 | ... 16 | 17 | @property 18 | @abstractmethod 19 | def environ(self) -> Any: 20 | ... 21 | 22 | @abstractmethod 23 | def getcwd(self) -> str: 24 | ... 25 | 26 | @abstractmethod 27 | def kill(self, pid: int, sig: int) -> None: 28 | ... 29 | 30 | @abstractmethod 31 | def putenv(self, key: str, value: str) -> None: 32 | ... 33 | 34 | 35 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/queue.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/sys.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from abc import abstractmethod 3 | from typing import List 4 | 5 | class VersionInfo: 6 | @property 7 | @abstractmethod 8 | def major(self) -> int: 9 | ... 10 | 11 | @property 12 | @abstractmethod 13 | def micro(self) -> int: 14 | ... 15 | 16 | @property 17 | @abstractmethod 18 | def minor(self) -> int: 19 | ... 20 | 21 | @property 22 | @abstractmethod 23 | def releaselevel(self) -> str: 24 | ... 25 | 26 | @property 27 | @abstractmethod 28 | def serial(self) -> int: 29 | ... 30 | 31 | 32 | class IExports: 33 | @property 34 | @abstractmethod 35 | def argv(self) -> List[str]: 36 | ... 37 | 38 | @property 39 | @abstractmethod 40 | def byteorder(self) -> str: 41 | ... 42 | 43 | @property 44 | @abstractmethod 45 | def hexversion(self) -> int: 46 | ... 47 | 48 | @property 49 | @abstractmethod 50 | def maxsize(self) -> int: 51 | ... 52 | 53 | @property 54 | @abstractmethod 55 | def maxunicode(self) -> int: 56 | ... 57 | 58 | @property 59 | @abstractmethod 60 | def path(self) -> List[str]: 61 | ... 62 | 63 | @property 64 | @abstractmethod 65 | def platform(self) -> str: 66 | ... 67 | 68 | @property 69 | @abstractmethod 70 | def prefix(self) -> str: 71 | ... 72 | 73 | @property 74 | @abstractmethod 75 | def version(self) -> str: 76 | ... 77 | 78 | @property 79 | @abstractmethod 80 | def version_info(self) -> VersionInfo: 81 | ... 82 | 83 | 84 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/time.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import Tuple 3 | 4 | class IExports: 5 | @property 6 | @abstractmethod 7 | def altzone(self) -> int: 8 | ... 9 | 10 | @property 11 | @abstractmethod 12 | def daylight(self) -> int: 13 | ... 14 | 15 | @property 16 | @abstractmethod 17 | def timezone(self) -> int: 18 | ... 19 | 20 | @property 21 | @abstractmethod 22 | def tzname(self) -> Tuple[str, str]: 23 | ... 24 | 25 | @abstractmethod 26 | def monotonic(self) -> float: 27 | ... 28 | 29 | @abstractmethod 30 | def perf_counter(self) -> float: 31 | ... 32 | 33 | @abstractmethod 34 | def process_time(self) -> float: 35 | ... 36 | 37 | @abstractmethod 38 | def sleep(self, secs: float) -> None: 39 | ... 40 | 41 | @abstractmethod 42 | def time(self) -> float: 43 | ... 44 | 45 | 46 | -------------------------------------------------------------------------------- /_tbnf/fable_modules/fable_python/stdlib/tk_inter.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from abc import abstractmethod 3 | from typing import (Callable, Optional) 4 | 5 | class Event: 6 | @property 7 | @abstractmethod 8 | def x(self) -> int: 9 | ... 10 | 11 | @property 12 | @abstractmethod 13 | def y(self) -> int: 14 | ... 15 | 16 | 17 | class Misc: 18 | @abstractmethod 19 | def bind(self, sequence: str, func: Callable[[Event], None]) -> Optional[str]: 20 | ... 21 | 22 | 23 | class Wm: 24 | pass 25 | 26 | -------------------------------------------------------------------------------- /_tbnf/src/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_tbnf/src/main.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from array import array 3 | from typing import (List, Tuple, MutableSequence) 4 | from ..fable_modules.fable_library.list import empty 5 | from ..fable_modules.fable_library.string import (to_console, printf) 6 | from .analysis import (build_analyzer, Analyzer) 7 | from .grammar import (node, position, definition) 8 | 9 | x : node = node(8, 5) 10 | 11 | z : definition = definition(1, { 12 | "define": empty(), 13 | "lhs": "2", 14 | "pos": position(0, 0, "") 15 | }) 16 | 17 | def main(a: int, b: int, c: int) -> MutableSequence[int]: 18 | arg10 : int = (a + (b // c)) or 0 19 | to_console(printf("%d"))(arg10) 20 | x_1 : Tuple[List[definition], Analyzer] = build_analyzer([definition(1, { 21 | "define": empty(), 22 | "lhs": "Float", 23 | "pos": position(0, 0, "") 24 | })]) 25 | return array("i", [1, 2, 3, 4]) 26 | 27 | 28 | -------------------------------------------------------------------------------- /_tbnf/src/op.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from .exceptions import NoBaseName 3 | from .grammar import monot 4 | 5 | def basename(t_mut: monot) -> str: 6 | while True: 7 | (t,) = (t_mut,) 8 | if ((t.tag == 3) or (t.tag == 0)) or (t.tag == 4): 9 | raise NoBaseName(t) 10 | 11 | elif t.tag == 2: 12 | t_mut = t.fields[0] 13 | continue 14 | 15 | else: 16 | return t.fields[0] 17 | 18 | break 19 | 20 | 21 | -------------------------------------------------------------------------------- /_tbnf/src/resource_keys.py: -------------------------------------------------------------------------------- 1 | 2 | ocaml_rts_file : str = "ocaml.rts_file" 3 | 4 | -------------------------------------------------------------------------------- /_tbnf/src/utils.py: -------------------------------------------------------------------------------- 1 | from array import array 2 | from typing import (Iterable, List, MutableSequence, Tuple, Any, TypeVar, Optional, Callable) 3 | from ..fable_modules.fable_library.list import (FSharpList, is_empty, head, tail, cons, singleton) 4 | from ..fable_modules.fable_library.option import some 5 | from ..fable_modules.fable_library.range import range_char 6 | from ..fable_modules.fable_library.seq import (to_array, delay, map) 7 | from ..fable_modules.fable_library.string import (replace, to_text, printf) 8 | from ..fable_modules.fable_library.system_text import (StringBuilder__ctor_Z721C83C5, StringBuilder__Append_Z721C83C5, StringBuilder__Append_244C7CD6) 9 | from ..fable_modules.fable_library.types import to_string 10 | from ..fable_modules.fable_library.util import (ignore, equals) 11 | 12 | a_ = TypeVar("a_") 13 | 14 | b_ = TypeVar("b_") 15 | 16 | lower_chars : List[str] = to_array(delay(lambda _unit=None: map(lambda a: a, range_char("a", "z")))) 17 | 18 | upper_chars : List[str] = to_array(delay(lambda _unit=None: map(lambda a: a, range_char("A", "Z")))) 19 | 20 | sample_unicodes : MutableSequence[int] = array("i", [20320, 26159, 22612, 33778, 21527]) 21 | 22 | lower_range : Tuple[str, str] = ("a", "z") 23 | 24 | upper_range : Tuple[str, str] = ("A", "Z") 25 | 26 | unicode_range : Tuple[str, str] = ("一", "龥") 27 | 28 | digit_range : Tuple[str, str] = ("0", "9") 29 | 30 | def is_digit(c: str) -> bool: 31 | if "0" <= c: 32 | return c <= "9" 33 | 34 | else: 35 | return False 36 | 37 | 38 | 39 | def is_upper(c: str) -> bool: 40 | if "A" <= c: 41 | return c <= "Z" 42 | 43 | else: 44 | return False 45 | 46 | 47 | 48 | def is_lower(c: str) -> bool: 49 | if "a" <= c: 50 | return c <= "z" 51 | 52 | else: 53 | return False 54 | 55 | 56 | 57 | def is_unicode(c: str) -> bool: 58 | if "一" <= c: 59 | return c <= "龥" 60 | 61 | else: 62 | return False 63 | 64 | 65 | 66 | def _escapeString(s: str) -> str: 67 | sb : Any = StringBuilder__ctor_Z721C83C5("\"") 68 | for i in range(0, (len(s) - 1) + 1, 1): 69 | def arrow_15(s: str=s) -> Any: 70 | match_value : str = s[i] 71 | return StringBuilder__Append_Z721C83C5(sb, "\\t") if (match_value == "\t") else (StringBuilder__Append_Z721C83C5(sb, "\\n") if (match_value == "\n") else (StringBuilder__Append_Z721C83C5(sb, "\\r") if (match_value == "\r") else (StringBuilder__Append_Z721C83C5(sb, "\\\"") if (match_value == "\"") else (StringBuilder__Append_Z721C83C5(sb, "\\\\") if (match_value == "\\") else (StringBuilder__Append_244C7CD6(sb, match_value)))))) 72 | 73 | ignore(arrow_15()) 74 | ignore(StringBuilder__Append_Z721C83C5(sb, "\"")) 75 | return to_string(sb) 76 | 77 | 78 | def i_to_u4(i: int) -> str: 79 | return "\\u" + replace(to_text(printf("%4X"))(i), " ", "0") 80 | 81 | 82 | def _escapeStringSingleQuoted(s: str) -> str: 83 | sb : Any = StringBuilder__ctor_Z721C83C5("\u0027") 84 | for i in range(0, (len(s) - 1) + 1, 1): 85 | def arrow_23(s: str=s) -> Any: 86 | match_value : str = s[i] 87 | return StringBuilder__Append_Z721C83C5(sb, "\\t") if (match_value == "\t") else (StringBuilder__Append_Z721C83C5(sb, "\\n") if (match_value == "\n") else (StringBuilder__Append_Z721C83C5(sb, "\\r") if (match_value == "\r") else (StringBuilder__Append_Z721C83C5(sb, "\\\u0027") if (match_value == "\u0027") else (StringBuilder__Append_Z721C83C5(sb, "\\\\") if (match_value == "\\") else (StringBuilder__Append_244C7CD6(sb, match_value)))))) 88 | 89 | ignore(arrow_23()) 90 | ignore(StringBuilder__Append_Z721C83C5(sb, "\u0027")) 91 | return to_string(sb) 92 | 93 | 94 | def escape_string_single_quoted(s: str) -> str: 95 | return _escapeStringSingleQuoted(s) 96 | 97 | 98 | def escape_string(s: str) -> str: 99 | return _escapeString(s) 100 | 101 | 102 | def capitalized(s: str) -> str: 103 | if s == "": 104 | return s 105 | 106 | else: 107 | return s[0].upper() + s[1:(len(s) - 1) + 1] 108 | 109 | 110 | 111 | def List_tryLookup(key_mut: a_, x_mut: FSharpList[Tuple[a_, b_]]) -> Optional[b_]: 112 | while True: 113 | (key, x) = (key_mut, x_mut) 114 | if not is_empty(x): 115 | if equals(head(x)[0], key): 116 | return some(head(x)[1]) 117 | 118 | elif not is_empty(x): 119 | key_mut = key 120 | x_mut = tail(x) 121 | continue 122 | 123 | else: 124 | raise Exception("Match failure") 125 | 126 | 127 | else: 128 | return None 129 | 130 | break 131 | 132 | 133 | def List_lookup(key_mut: a_, x_mut: FSharpList[Tuple[a_, b_]]) -> b_: 134 | while True: 135 | (key, x) = (key_mut, x_mut) 136 | if not is_empty(x): 137 | if equals(head(x)[0], key): 138 | return head(x)[1] 139 | 140 | elif not is_empty(x): 141 | key_mut = key 142 | x_mut = tail(x) 143 | continue 144 | 145 | else: 146 | raise Exception("Match failure") 147 | 148 | 149 | else: 150 | raise Exception("key not found") 151 | 152 | break 153 | 154 | 155 | def List_replaceWith(key: a_, func: Callable[[Optional[b_]], b_], xs: FSharpList[Tuple[a_, b_]]) -> FSharpList[Tuple[a_, b_]]: 156 | if not is_empty(xs): 157 | if equals(head(xs)[0], key): 158 | return cons((head(xs)[0], func(some(head(xs)[1]))), tail(xs)) 159 | 160 | elif not is_empty(xs): 161 | return cons(head(xs), List_replaceWith(key, func, tail(xs))) 162 | 163 | else: 164 | raise Exception("Match failure") 165 | 166 | 167 | else: 168 | return singleton((key, func(None))) 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /backend_pygments/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thautwarm/cross-editor-syntax-highlighter/7be87440d6b011397f1372e6c5cd0e8e21150658/backend_pygments/__init__.py -------------------------------------------------------------------------------- /backend_pygments/lua_sh_construct.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations as __01asda1ha 2 | from lark import Token as token 3 | import dataclasses as dataclasses 4 | import typing as typing 5 | from .lua_sh_require import (isControl,isFuncDecl,isFuncCall,isUnaryOperator,isBinaryOperator,isNumber,isAttr,isVariable,isString,isLiteral,isKeyword) 6 | 7 | -------------------------------------------------------------------------------- /backend_pygments/lua_sh_require.py: -------------------------------------------------------------------------------- 1 | from lark import Token 2 | from pygments import token 3 | from pygments.lexer import Lexer 4 | from pygments.formatters import LatexFormatter 5 | from sortedcontainers import * 6 | 7 | _style_cache = SortedDict() 8 | 9 | 10 | def clear_cache(): 11 | _style_cache.clear() 12 | 13 | def get_cache(): 14 | return _style_cache 15 | 16 | def isKeyword(tk: Token): 17 | _style_cache[tk.start_pos] = (token.Keyword, tk.end_pos) 18 | return 0 19 | 20 | def isLiteral(tk: Token): 21 | _style_cache[tk.start_pos] = (token.Literal, tk.end_pos) 22 | return 0 23 | 24 | def isString(tk: Token): 25 | _style_cache[tk.start_pos] = (token.String, tk.end_pos) 26 | 27 | def isVariable(tk: Token): 28 | _style_cache[tk.start_pos] = (token.Name.Variable, tk.end_pos) 29 | return 0 30 | 31 | def isAttr(tk: Token): 32 | _style_cache[tk.start_pos] = (token.Name.Attribute, tk.end_pos) 33 | return 0 34 | 35 | def isBinaryOperator(tk: Token): 36 | _style_cache[tk.start_pos] = (token.Operator, tk.end_pos) 37 | return 0 38 | 39 | def isUnaryOperator(tk: Token): 40 | _style_cache[tk.start_pos] = (token.Name.Variable.Instance, tk.end_pos) 41 | return 0 42 | 43 | def isNumber(tk: Token): 44 | _style_cache[tk.start_pos] = (token.Number, tk.end_pos) 45 | return 0 46 | 47 | def isFuncCall(tk: Token): 48 | _style_cache[tk.start_pos] = (token.Name.Function, tk.end_pos) 49 | return 0 50 | 51 | def isFuncDecl(tk: Token): 52 | _style_cache[tk.start_pos] = (token.Keyword.Declaration, tk.end_pos) 53 | return 0 54 | 55 | def isControl(tk: Token): 56 | _style_cache[tk.start_pos] = (token.Keyword.Namespace, tk.end_pos) 57 | return 0 58 | 59 | 60 | def highlight(src: str): 61 | n = len(src) 62 | i = 0 63 | no_highlight_start = 0 64 | while i < n: 65 | if style_record := _style_cache.get(i): 66 | if no_highlight_start != i: 67 | yield i, token.Text, src[no_highlight_start:i] 68 | scope, end_pos = style_record 69 | yield i, scope, src[i: end_pos] 70 | i = end_pos 71 | no_highlight_start = i 72 | else: 73 | i += 1 74 | 75 | if no_highlight_start != i: 76 | yield i, token.Text, src[no_highlight_start:i] 77 | clear_cache() 78 | 79 | class MyLexer(Lexer): 80 | def get_tokens_unprocessed(self, text): 81 | return highlight(text) 82 | 83 | 84 | -------------------------------------------------------------------------------- /backend_vscode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/test/** 4 | out/**/*.map 5 | src/** 6 | static/static.png 7 | .gitignore 8 | tsconfig.json 9 | vsc-extension-quickstart.md 10 | tslint.json -------------------------------------------------------------------------------- /backend_vscode/language-configuration.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "comments": { 4 | "lineComment": "#" 5 | }, 6 | "brackets": [ 7 | ["{", "}"], 8 | ["[", "]"], 9 | ["(", ")"] 10 | ], 11 | "surroundingPairs": [ 12 | ["{", "}"], 13 | ["[", "]"], 14 | ["(", ")"], 15 | ["'", "'"], 16 | ["\"", "\""], 17 | ["`", "`"] 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /backend_vscode/out/extension.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.activate = void 0; 4 | const vscode = require("vscode"); 5 | const lua_sh_provider_1 = require("./lua_sh_provider"); 6 | function activate(context) { 7 | context.subscriptions.push(vscode.languages.registerDocumentSemanticTokensProvider({ scheme: 'file', language: 'rua' }, new lua_sh_provider_1.DocumentSemanticTokensProvider(), lua_sh_provider_1.legend)); 8 | } 9 | exports.activate = activate; 10 | //# sourceMappingURL=extension.js.map -------------------------------------------------------------------------------- /backend_vscode/out/extension.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,uDAA2E;AAE3E,SAAgB,QAAQ,CAAC,OAAgC;IACrD,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,sCAAsC,CAC9E,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EACnC,IAAI,gDAA8B,EAAE,EAAE,wBAAM,CAAC,CAAC,CAAC;AACvD,CAAC;AAJD,4BAIC"} -------------------------------------------------------------------------------- /backend_vscode/out/lua_shListener.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // Generated from .\lua_sh.g4 by ANTLR 4.9.0-SNAPSHOT 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | //# sourceMappingURL=lua_shListener.js.map -------------------------------------------------------------------------------- /backend_vscode/out/lua_shListener.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lua_shListener.js","sourceRoot":"","sources":["../src/lua_shListener.ts"],"names":[],"mappings":";AAAA,qDAAqD"} -------------------------------------------------------------------------------- /backend_vscode/out/lua_sh_provider.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.DocumentSemanticTokensProvider = exports.render_text = exports.legend = void 0; 4 | const vscode = require("vscode"); 5 | const antlr = require("antlr4ts"); 6 | const sh = require("./lua_sh_require"); 7 | const lua_parser = require("./lua_shParser"); 8 | const lua_lexer = require("./lua_shLexer"); 9 | const antlr4ts_1 = require("antlr4ts"); 10 | exports.legend = new vscode.SemanticTokensLegend(sh.tokenTypesLegend, sh.tokenModifiersLegend); 11 | function render_text(text) { 12 | const inputStream = antlr.CharStreams.fromString(text); 13 | const lexer = new lua_lexer.lua_shLexer(inputStream); 14 | const tokenStram = new antlr4ts_1.CommonTokenStream(lexer); 15 | const parser = new lua_parser.lua_shParser(tokenStram); 16 | parser.start(); 17 | } 18 | exports.render_text = render_text; 19 | class DocumentSemanticTokensProvider { 20 | async provideDocumentSemanticTokens(document, _) { 21 | sh.clearCache(); 22 | let cache = sh.getCache(); 23 | render_text(document.getText()); 24 | const builder = new vscode.SemanticTokensBuilder(); 25 | for (let [scope, token] of cache) { 26 | builder.push(token.line - 1, token.charPositionInLine, token.stopIndex - token.startIndex + 1, scope, 0); 27 | } 28 | return builder.build(); 29 | } 30 | } 31 | exports.DocumentSemanticTokensProvider = DocumentSemanticTokensProvider; 32 | //# sourceMappingURL=lua_sh_provider.js.map -------------------------------------------------------------------------------- /backend_vscode/out/lua_sh_provider.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lua_sh_provider.js","sourceRoot":"","sources":["../src/lua_sh_provider.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,kCAAiC;AACjC,uCAAsC;AACtC,6CAA4C;AAC5C,2CAA0C;AAE1C,uCAA4C;AAE/B,QAAA,MAAM,GAAG,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAAE,CAAC,gBAAgB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;AAGpG,SAAgB,WAAW,CAAC,IAAY;IACvC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,IAAI,4BAAiB,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC;AAND,kCAMC;AAGD,MAAa,8BAA8B;IAC1C,KAAK,CAAC,6BAA6B,CAAC,QAA6B,EAAE,CAA2B;QAC7F,EAAE,CAAC,UAAU,EAAE,CAAC;QACV,IAAI,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;QACzB,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACzD,KAAI,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,EACzB;YACI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,SAAS,GAAC,KAAK,CAAC,UAAU,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;SAC1G;QACP,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACD;AAZD,wEAYC"} -------------------------------------------------------------------------------- /backend_vscode/out/lua_sh_require.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.clearCache = exports.getCache = exports.isKeyword = exports.isLiteral = exports.isString = exports.isAttr = exports.isVariable = exports.isNumber = exports.isBinaryOperator = exports.isUnaryOperator = exports.isFuncCall = exports.isFuncDecl = exports.isControl = exports.tokenModifiersLegend = exports.tokenTypesLegend = void 0; 4 | exports.tokenTypesLegend = [ 5 | 'comment', 6 | 'string', 7 | 'keyword', 8 | 'number', 9 | 'regexp', 10 | 'operator', 11 | 'namespace', 12 | 'type', 13 | 'struct', 14 | 'class', 15 | 'interface', 16 | 'enum', 17 | 'typeParameter', 18 | 'function', 19 | 'method', 20 | 'decorator', 21 | 'macro', 22 | 'variable', 23 | 'parameter', 24 | 'property', 25 | 'label' 26 | ]; 27 | function getNativeTokenId(s) { 28 | return exports.tokenTypesLegend.indexOf(s); 29 | } 30 | class Scope { 31 | } 32 | Scope.Keyword = getNativeTokenId("keyword"); 33 | Scope.Number = getNativeTokenId("number"); 34 | Scope.String = getNativeTokenId("string"); 35 | Scope.Operator = getNativeTokenId("operator"); 36 | Scope.Namespace = getNativeTokenId("namespace"); 37 | Scope.Function = getNativeTokenId("function"); 38 | Scope.Variable = getNativeTokenId("variable"); 39 | Scope.Label = getNativeTokenId("label"); 40 | Scope.Property = getNativeTokenId("property"); 41 | Scope.Method = getNativeTokenId("method"); 42 | Scope.Interface = getNativeTokenId("interface"); 43 | Scope.Struct = getNativeTokenId("struct"); 44 | exports.tokenModifiersLegend = [ 45 | 'declaration', 46 | 'documentation', 47 | 'readonly', 48 | 'static', 49 | 'abstract', 50 | 'deprecated', 51 | 'modification', 52 | 'async' 53 | ]; 54 | let render_cache = new Array(); 55 | function isControl(x) { 56 | render_cache.push([Scope.Label, x]); 57 | return 0; 58 | } 59 | exports.isControl = isControl; 60 | function isFuncDecl(x) { 61 | render_cache.push([Scope.Interface, x]); 62 | return 0; 63 | } 64 | exports.isFuncDecl = isFuncDecl; 65 | function isFuncCall(x) { 66 | render_cache.push([Scope.Method, x]); 67 | return 0; 68 | } 69 | exports.isFuncCall = isFuncCall; 70 | function isUnaryOperator(x) { 71 | render_cache.push([Scope.Namespace, x]); 72 | return 0; 73 | } 74 | exports.isUnaryOperator = isUnaryOperator; 75 | function isBinaryOperator(x) { 76 | render_cache.push([Scope.Operator, x]); 77 | return 0; 78 | } 79 | exports.isBinaryOperator = isBinaryOperator; 80 | function isNumber(x) { 81 | render_cache.push([Scope.Number, x]); 82 | return 0; 83 | } 84 | exports.isNumber = isNumber; 85 | function isVariable(x) { 86 | render_cache.push([Scope.Variable, x]); 87 | return 0; 88 | } 89 | exports.isVariable = isVariable; 90 | function isAttr(x) { 91 | render_cache.push([Scope.Property, x]); 92 | return 0; 93 | } 94 | exports.isAttr = isAttr; 95 | function isString(x) { 96 | render_cache.push([Scope.String, x]); 97 | return 0; 98 | } 99 | exports.isString = isString; 100 | function isLiteral(x) { 101 | render_cache.push([Scope.Struct, x]); 102 | return 0; 103 | } 104 | exports.isLiteral = isLiteral; 105 | function isKeyword(x) { 106 | render_cache.push([Scope.Keyword, x]); 107 | return 0; 108 | } 109 | exports.isKeyword = isKeyword; 110 | function getCache() { 111 | return render_cache; 112 | } 113 | exports.getCache = getCache; 114 | function clearCache() { 115 | render_cache = []; 116 | } 117 | exports.clearCache = clearCache; 118 | //# sourceMappingURL=lua_sh_require.js.map -------------------------------------------------------------------------------- /backend_vscode/out/lua_sh_require.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lua_sh_require.js","sourceRoot":"","sources":["../src/lua_sh_require.ts"],"names":[],"mappings":"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"} -------------------------------------------------------------------------------- /backend_vscode/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-tbnf-lua", 3 | "displayName": "vscode-tbnf-lua", 4 | "description": "example", 5 | "version": "0.0.1", 6 | "publisher": "GReSummer", 7 | "private": true, 8 | "license": "MIT", 9 | "icon": "static/icon.png", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/thautwarm/cross-editor-syntax-highlighter/backend-vscode" 13 | }, 14 | "engines": { 15 | "vscode": "^1.42.0" 16 | }, 17 | "categories": [ 18 | "Other" 19 | ], 20 | "activationEvents": [ 21 | "onLanguage:rua" 22 | ], 23 | "main": "./out/extension.js", 24 | "contributes": { 25 | "languages": [ 26 | { 27 | "id": "rua", 28 | "extensions": [ 29 | ".rua" 30 | ], 31 | "configuration": "./language-configuration.json" 32 | } 33 | ] 34 | }, 35 | "scripts": { 36 | "vscode:prepublish": "npm run compile", 37 | "compile": "tsc -p ./", 38 | "antlr4ts": "antlr4ts -visitor src/lua_sh.g4", 39 | "lint": "eslint . --ext .ts,.tsx", 40 | "watch": "tsc -watch -p ./" 41 | }, 42 | "devDependencies": { 43 | "@types/node": "^12.12.0", 44 | "@types/vscode": "^1.42.0", 45 | "@typescript-eslint/eslint-plugin": "^4.16.0", 46 | "@typescript-eslint/parser": "^4.16.0", 47 | "antlr4ts-cli": "^0.5.0-alpha.4", 48 | "eslint": "^7.21.0", 49 | "typescript": "^4.4.3" 50 | }, 51 | "dependencies": { 52 | "antlr4ts": "^0.5.0-alpha.4" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /backend_vscode/src/extension.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import { DocumentSemanticTokensProvider, legend } from "./lua_sh_provider"; 3 | 4 | export function activate(context: vscode.ExtensionContext) { 5 | context.subscriptions.push(vscode.languages.registerDocumentSemanticTokensProvider( 6 | { scheme: 'file', language: 'rua' }, 7 | new DocumentSemanticTokensProvider(), legend)); 8 | } 9 | -------------------------------------------------------------------------------- /backend_vscode/src/lua_sh_provider.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode" 2 | import * as antlr from "antlr4ts" 3 | import * as sh from "./lua_sh_require" 4 | import * as lua_parser from "./lua_shParser" 5 | import * as lua_lexer from "./lua_shLexer" 6 | 7 | import { CommonTokenStream } from "antlr4ts" 8 | 9 | export const legend = new vscode.SemanticTokensLegend(sh.tokenTypesLegend, sh.tokenModifiersLegend); 10 | 11 | 12 | export function render_text(text: string) { 13 | const inputStream = antlr.CharStreams.fromString(text); 14 | const lexer = new lua_lexer.lua_shLexer(inputStream); 15 | const tokenStram = new CommonTokenStream(lexer); 16 | const parser = new lua_parser.lua_shParser(tokenStram); 17 | parser.start(); 18 | } 19 | 20 | 21 | export class DocumentSemanticTokensProvider implements vscode.DocumentSemanticTokensProvider { 22 | async provideDocumentSemanticTokens(document: vscode.TextDocument, _: vscode.CancellationToken): Promise { 23 | sh.clearCache(); 24 | let cache = sh.getCache() 25 | render_text(document.getText()); 26 | const builder = new vscode.SemanticTokensBuilder(); 27 | for(let [scope, token] of cache) 28 | { 29 | builder.push(token.line - 1, token.charPositionInLine, token.stopIndex-token.startIndex + 1, scope, 0); 30 | } 31 | return builder.build(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /backend_vscode/src/lua_sh_require.ts: -------------------------------------------------------------------------------- 1 | import * as antlr from 'antlr4ts' 2 | 3 | export const tokenTypesLegend = [ 4 | 'comment', 5 | 'string', 6 | 'keyword', 7 | 'number', 8 | 'regexp', 9 | 'operator', 10 | 'namespace', 11 | 'type', 12 | 'struct', 13 | 'class', 14 | 'interface', 15 | 'enum', 16 | 'typeParameter', 17 | 'function', 18 | 'method', 19 | 'decorator', 20 | 'macro', 21 | 'variable', 22 | 'parameter', 23 | 'property', 24 | 'label' 25 | ]; 26 | 27 | function getNativeTokenId(s: string): number { 28 | return tokenTypesLegend.indexOf(s); 29 | } 30 | 31 | class Scope { 32 | public static readonly Keyword = getNativeTokenId("keyword"); 33 | public static readonly Number = getNativeTokenId("number"); 34 | public static readonly String = getNativeTokenId("string"); 35 | public static readonly Operator = getNativeTokenId("operator"); 36 | public static readonly Namespace = getNativeTokenId("namespace"); 37 | public static readonly Function = getNativeTokenId("function"); 38 | public static readonly Variable = getNativeTokenId("variable"); 39 | public static readonly Label = getNativeTokenId("label"); 40 | public static readonly Property = getNativeTokenId("property"); 41 | public static readonly Method = getNativeTokenId("method"); 42 | public static readonly Interface = getNativeTokenId("interface"); 43 | public static readonly Struct = getNativeTokenId("struct"); 44 | 45 | } 46 | 47 | 48 | 49 | 50 | 51 | export const tokenModifiersLegend = [ 52 | 'declaration', 53 | 'documentation', 54 | 'readonly', 55 | 'static', 56 | 'abstract', 57 | 'deprecated', 58 | 'modification', 59 | 'async' 60 | ]; 61 | 62 | type scope = number 63 | let render_cache = new Array<[scope, antlr.Token]>(); 64 | 65 | export function isControl(x: antlr.Token) { 66 | render_cache.push([Scope.Label, x]); 67 | return 0; 68 | } 69 | 70 | export function isFuncDecl(x: antlr.Token) { 71 | render_cache.push([Scope.Interface, x]); 72 | return 0 73 | } 74 | 75 | export function isFuncCall(x: antlr.Token) { 76 | render_cache.push([Scope.Method, x]); 77 | return 0 78 | } 79 | 80 | export function isUnaryOperator(x: antlr.Token) { 81 | render_cache.push([Scope.Namespace, x]); 82 | return 0 83 | } 84 | 85 | export function isBinaryOperator(x: antlr.Token) { 86 | render_cache.push([Scope.Operator, x]); 87 | return 0 88 | } 89 | 90 | export function isNumber(x: antlr.Token) { 91 | render_cache.push([Scope.Number, x]); 92 | return 0 93 | } 94 | 95 | export function isVariable(x: antlr.Token) { 96 | render_cache.push([Scope.Variable, x]); 97 | return 0 98 | } 99 | 100 | export function isAttr(x: antlr.Token) { 101 | render_cache.push([Scope.Property, x]); 102 | return 0 103 | } 104 | 105 | export function isString(x: antlr.Token) { 106 | render_cache.push([Scope.String, x]); 107 | return 0 108 | } 109 | 110 | export function isLiteral(x: antlr.Token) { 111 | render_cache.push([Scope.Struct, x]); 112 | return 0 113 | } 114 | 115 | export function isKeyword(x: antlr.Token) { 116 | render_cache.push([Scope.Keyword, x]); 117 | return 0 118 | } 119 | 120 | 121 | export function getCache() { 122 | return render_cache; 123 | } 124 | 125 | export function clearCache() { 126 | render_cache = []; 127 | } -------------------------------------------------------------------------------- /backend_vscode/src/rename.tbnf.py: -------------------------------------------------------------------------------- 1 | def rename_type(x): 2 | if x == "int": 3 | return "number" 4 | if x == "float": 5 | return "number" 6 | if x == "token": 7 | return "Token" 8 | if x == "list": 9 | return "Array" 10 | if x == "str": 11 | return "string" 12 | return x -------------------------------------------------------------------------------- /backend_vscode/testit.rua: -------------------------------------------------------------------------------- 1 | function f(a, b, ...) 2 | 1 - -g(a, b, c()) 3 | end -------------------------------------------------------------------------------- /backend_vscode/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "strictPropertyInitialization": false, 5 | "target": "es2019", 6 | "lib": ["ES2019"], 7 | "outDir": "out", 8 | "sourceMap": true, 9 | "rootDir": "src", 10 | "strict": true 11 | }, 12 | "exclude": ["node_modules", ".vscode-test"] 13 | } -------------------------------------------------------------------------------- /base16_applepips.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Base16 Apple Pips Light 4 | by Jan T. Sott 5 | 6 | Pygments template by Jan T. Sott (https://github.com/idleberg) 7 | Created with Base16 Builder by Chris Kempson (https://github.com/chriskempson/base16-builder) 8 | """ 9 | 10 | from pygments.style import Style 11 | from pygments.token import Keyword, Name, Comment, String, Error, Text, \ 12 | Number, Operator, Generic, Whitespace, Punctuation, Other, Literal 13 | 14 | 15 | BACKGROUND = "#ffffff" 16 | CURRENT_LINE = "#d5d5d5" 17 | SELECTION = "#a8aaaa" 18 | FOREGROUND = "#374546" 19 | COMMENT = "#929495" 20 | RED = "#e92d46" 21 | ORANGE = "#e16712" 22 | YELLOW = "#efb554" 23 | GREEN = "#78bb86" 24 | AQUA = "#00b5b0" 25 | BLUE = "#00afd6" 26 | PURPLE = "#ef91a1" 27 | 28 | 29 | class base16_applepips_light(Style): 30 | 31 | default_style = '' 32 | 33 | background_color = BACKGROUND 34 | highlight_color = SELECTION 35 | 36 | background_color = BACKGROUND 37 | highlight_color = SELECTION 38 | 39 | styles = { 40 | # No corresponding class for the following: 41 | Text: FOREGROUND, # class: '' 42 | Whitespace: "", # class: 'w' 43 | Error: RED, # class: 'err' 44 | Other: "", # class 'x' 45 | 46 | Comment: COMMENT, # class: 'c' 47 | Comment.Multiline: "", # class: 'cm' 48 | Comment.Preproc: "", # class: 'cp' 49 | Comment.Single: "", # class: 'c1' 50 | Comment.Special: "", # class: 'cs' 51 | 52 | Keyword: PURPLE, # class: 'k' 53 | Keyword.Constant: "", # class: 'kc' 54 | Keyword.Declaration: "", # class: 'kd' 55 | Keyword.Namespace: AQUA, # class: 'kn' 56 | Keyword.Pseudo: "", # class: 'kp' 57 | Keyword.Reserved: "", # class: 'kr' 58 | Keyword.Type: YELLOW, # class: 'kt' 59 | 60 | Operator: AQUA, # class: 'o' 61 | Operator.Word: "", # class: 'ow' - like keywords 62 | 63 | Punctuation: FOREGROUND, # class: 'p' 64 | 65 | Name: FOREGROUND, # class: 'n' 66 | Name.Attribute: BLUE, # class: 'na' - to be revised 67 | Name.Builtin: "", # class: 'nb' 68 | Name.Builtin.Pseudo: "", # class: 'bp' 69 | Name.Class: YELLOW, # class: 'nc' - to be revised 70 | Name.Constant: RED, # class: 'no' - to be revised 71 | Name.Decorator: AQUA, # class: 'nd' - to be revised 72 | Name.Entity: "", # class: 'ni' 73 | Name.Exception: RED, # class: 'ne' 74 | Name.Function: BLUE, # class: 'nf' 75 | Name.Property: "", # class: 'py' 76 | Name.Label: "", # class: 'nl' 77 | Name.Namespace: YELLOW, # class: 'nn' - to be revised 78 | Name.Other: BLUE, # class: 'nx' 79 | Name.Tag: AQUA, # class: 'nt' - like a keyword 80 | Name.Variable: RED, # class: 'nv' - to be revised 81 | Name.Variable.Class: "", # class: 'vc' - to be revised 82 | Name.Variable.Global: "", # class: 'vg' - to be revised 83 | Name.Variable.Instance: "", # class: 'vi' - to be revised 84 | 85 | Number: ORANGE, # class: 'm' 86 | Number.Float: "", # class: 'mf' 87 | Number.Hex: "", # class: 'mh' 88 | Number.Integer: "", # class: 'mi' 89 | Number.Integer.Long: "", # class: 'il' 90 | Number.Oct: "", # class: 'mo' 91 | 92 | Literal: ORANGE, # class: 'l' 93 | Literal.Date: GREEN, # class: 'ld' 94 | 95 | String: GREEN, # class: 's' 96 | String.Backtick: "", # class: 'sb' 97 | String.Char: FOREGROUND, # class: 'sc' 98 | String.Doc: COMMENT, # class: 'sd' - like a comment 99 | String.Double: "", # class: 's2' 100 | String.Escape: ORANGE, # class: 'se' 101 | String.Heredoc: "", # class: 'sh' 102 | String.Interpol: ORANGE, # class: 'si' 103 | String.Other: "", # class: 'sx' 104 | String.Regex: "", # class: 'sr' 105 | String.Single: "", # class: 's1' 106 | String.Symbol: "", # class: 'ss' 107 | 108 | Generic: "", # class: 'g' 109 | Generic.Deleted: RED, # class: 'gd', 110 | Generic.Emph: "italic", # class: 'ge' 111 | Generic.Error: "", # class: 'gr' 112 | Generic.Heading: "bold " + FOREGROUND, # class: 'gh' 113 | Generic.Inserted: GREEN, # class: 'gi' 114 | Generic.Output: "", # class: 'go' 115 | Generic.Prompt: "bold " + COMMENT, # class: 'gp' 116 | Generic.Strong: "bold", # class: 'gs' 117 | Generic.Subheading: "bold " + AQUA, # class: 'gu' 118 | Generic.Traceback: "", # class: 'gt' 119 | } -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | cp -Recurse -Force ../_tbnf ./ -------------------------------------------------------------------------------- /lua.tbnf: -------------------------------------------------------------------------------- 1 | extern var isKeyword : token -> int 2 | extern var isLiteral : token -> int 3 | extern var isString : token -> int 4 | extern var isVariable : token -> int 5 | extern var isAttr : token -> int 6 | extern var isNumber : token -> int 7 | extern var isBinaryOperator : token -> int 8 | extern var isUnaryOperator : token -> int 9 | extern var isFuncCall : token -> int 10 | extern var isFuncDecl : token -> int 11 | extern var isControl : token -> int 12 | 13 | 14 | nempty_list(elt) 15 | : elt { 0 } 16 | | nempty_list(elt) elt { 0 } 17 | 18 | nempty_seplist(sep, elt) 19 | : elt { 0 } 20 | | nempty_seplist(sep, elt) sep elt { 0 } 21 | 22 | allow_empty(sequence) 23 | : { 0 } 24 | | sequence { 0 } 25 | 26 | start : block { 0 } 27 | 28 | list(elt) : allow_empty(nempty_list(elt)) { 0 } 29 | 30 | seplist(sep, elt) : allow_empty(nempty_seplist(sep, elt)) { 0 } 31 | 32 | opt(value) : value { 0 } 33 | | { 0 } 34 | 35 | block : list(stat) opt(retstat) { 0 } 36 | 37 | retcolon : ";" { isControl($1) } 38 | | { 0 } 39 | 40 | retstat : "return" seplist(",", exp) retcolon { isKeyword($1) } 41 | 42 | name: { isVariable($1) } 43 | 44 | stat : ";" { 0 } 45 | | nempty_seplist(",", exp) "=" nempty_seplist(",", exp) { 0 } 46 | | exp { 0 } 47 | | "::" "::" { isControl($1);isControl($3) } 48 | | "break" 49 | { isKeyword($1) } 50 | | "goto" 51 | { isKeyword($1); isControl($2) } 52 | | "do" block "end" 53 | { isKeyword($1);isKeyword($3) } 54 | | "while" exp "do" block "end" 55 | { isKeyword($1); isKeyword($3);isKeyword($5) } 56 | | "repeat" block "until" exp 57 | { isKeyword($1); isKeyword($3) } 58 | | "if" exp "then" block list(elseif) opt(else) "end" 59 | { isKeyword($1); isKeyword($3);isKeyword($7) } 60 | | "for" "=" range "do" block "end" 61 | { isKeyword($1); isKeyword($3);isKeyword($5);isKeyword($7) } 62 | | "for" nempty_seplist(",", name) "in" nempty_seplist(",", exp) "do" block "end" 63 | { isKeyword($1); isKeyword($3);isKeyword($5);isKeyword($7) } 64 | | "local" "function" funcname "(" opt(parlist) ")" block "end" 65 | { isKeyword($1);isKeyword($2);isKeyword($4);isKeyword($6);isKeyword($8) } 66 | | "local" nempty_seplist(",", ) opt_assign_rhs 67 | { isKeyword($1) } 68 | 69 | opt_assign_rhs : 70 | "=" nempty_seplist(",", exp) { 0 } 71 | | { 0 } 72 | 73 | range : exp "," exp range_tail { 0 } 74 | range_tail : "," exp { 0 } 75 | | { 0 } 76 | 77 | elseif : "elseif" exp "then" block { isKeyword($1);isKeyword($3) } 78 | else : "else" block { isKeyword($1) } 79 | 80 | 81 | exp : binexp { 0 } 82 | binexp : binseq { 0 } 83 | 84 | binseq : binseq binop binoperand { 0 } 85 | | binoperand { 0 } 86 | 87 | binoperand : unaryexp { 0 } 88 | 89 | unaryexp : "#" exponent { isUnaryOperator($1) } 90 | | "-" exponent { isUnaryOperator($1) } 91 | | "~" exponent { isUnaryOperator($1) } 92 | | "not" exponent { isUnaryOperator($1) } 93 | | exponent { 0 } 94 | 95 | exponent : prefixexp "^" exponent { isBinaryOperator($2) } 96 | | prefixexp { 0 } 97 | 98 | prefixexp : { isVariable($1) } 99 | | "(" exp ")" { 0 } 100 | | prefixexp args { 0 } 101 | | prefixexp ":" args { isAttr($3) } 102 | | prefixexp "[" exp "]" { 0 } 103 | | prefixexp "." { isAttr($3) } 104 | | atom { 0 } 105 | 106 | atom : "nil" { isLiteral($1) } 107 | | "false" { isLiteral($1) } 108 | | "true" { isLiteral($1) } 109 | | { isNumber($1) } 110 | | { isString($1) } 111 | | { isString($1) } 112 | | "..." { isControl($1) } 113 | | functiondef { 0 } 114 | | tableconstructor { 0 } 115 | 116 | 117 | args : "(" seplist(",", exp) ")" { isFuncCall($1); isFuncCall($3) } 118 | | tableconstructor { 0 } 119 | | { isString($1) } 120 | 121 | functiondef : "function" opt(funcname) "(" opt(parlist) ")" block "end" 122 | { isKeyword($1); isKeyword($7);isFuncDecl($3); isFuncDecl($5) } 123 | 124 | varargs : "," "..." { isControl($2) } 125 | | { 0 } 126 | 127 | parlist : "..." { 0 } 128 | | nempty_seplist(",", name) varargs { 0 } 129 | 130 | tableconstructor : "{" nempty_seplist(fieldsep, field) opt(fieldsep) "}" { 0 } 131 | | "{" "}" { 0 } 132 | 133 | funcname : funcname "." { isAttr($3) } 134 | | funcname ":" { isAttr($3) } 135 | | { isVariable($1) } 136 | 137 | field : "[" exp "]" "=" exp { 0 } 138 | | "=" exp { isAttr($1) } 139 | | exp { 0 } 140 | 141 | fieldsep : "," { 0 } 142 | | ";" { 0 } 143 | 144 | binop : "or" { isBinaryOperator($1) } 145 | | "and" { isBinaryOperator($1) } 146 | | "<" { isBinaryOperator($1) } 147 | | ">" { isBinaryOperator($1) } 148 | | "<=" { isBinaryOperator($1) } 149 | | ">=" { isBinaryOperator($1) } 150 | | "~=" { isBinaryOperator($1) } 151 | | "==" { isBinaryOperator($1) } 152 | | "|" { isBinaryOperator($1) } 153 | | "~" { isBinaryOperator($1) } 154 | | "&" { isBinaryOperator($1) } 155 | | "<<" { isBinaryOperator($1) } 156 | | ">>" { isBinaryOperator($1) } 157 | | ".." { isBinaryOperator($1) } 158 | | "+" { isBinaryOperator($1) } 159 | | "-" { isBinaryOperator($1) } 160 | | "*" { isBinaryOperator($1) } 161 | | "/" { isBinaryOperator($1) } 162 | | "//" { isBinaryOperator($1) } 163 | | "%" { isBinaryOperator($1) } 164 | 165 | 166 | ignore SPACE, LINE_COMMENT 167 | 168 | LINE_COMMENT = "-" "-" (!"\n")* "\n"; 169 | SPACE = " " | "\t" | "\r" | "\n"; 170 | DIGIT = [0-9]; 171 | HEXCHAR = [0-9] | [a-z] | [A-Z]; 172 | UCHAR = [a-z] | [A-Z] | "_" ; 173 | NAME = UCHAR (UCHAR|DIGIT)*; 174 | INT = DIGIT+; 175 | INTEGRAL = INT ("." INT)? (("E" | "e") INT)?; 176 | HEX = "0x" HEXCHAR+; 177 | NUMERAL = HEX | INTEGRAL; 178 | STR_LIT = "\"" ("\\" _ | !"\"")* "\""; 179 | 180 | // [[.*]] 181 | NESTED_STR1 = "[" ("]" !"]"| !"]")* "]"; 182 | // [=[.*]=] 183 | NESTED_STR2 = 184 | "=" 185 | ( "[" (!"]" | "]" (!"=" | "=" !"]"))* "]" 186 | | ("=" !"]"| !"=")* 187 | ) 188 | "="; 189 | NESTED_STR = "[" (NESTED_STR1|NESTED_STR2) "]"; 190 | -------------------------------------------------------------------------------- /run.py: -------------------------------------------------------------------------------- 1 | from backend_pygments.lua_sh_parser import parser 2 | from backend_pygments.lua_sh_require import MyLexer 3 | from pygments import highlight 4 | from pygments.formatters import LatexFormatter, HtmlFormatter, Terminal256Formatter, TerminalTrueColorFormatter, latex 5 | from base16_applepips import base16_applepips_light 6 | from wisepy2 import wise 7 | 8 | formatters = { 9 | "latex": LatexFormatter, 10 | 'html': HtmlFormatter, 11 | 'term256': Terminal256Formatter, 12 | 'truecolor': TerminalTrueColorFormatter 13 | } 14 | 15 | def main(filename: str, format: str="latex"): 16 | set_color_cache = parser.parse 17 | src = open(filename, encoding='utf-8').read() 18 | set_color_cache(src) 19 | formatter = formatters[format](style=base16_applepips_light) 20 | if format == 'latex': 21 | print(formatter.get_style_defs()) 22 | print(highlight(src, MyLexer(), formatter)) 23 | 24 | if __name__ == '__main__': 25 | wise(main)() -------------------------------------------------------------------------------- /testit.rua: -------------------------------------------------------------------------------- 1 | function f(a, b, ...) 2 | 1 - -g(a, b, c()) 3 | end -------------------------------------------------------------------------------- /vscode_sh_template/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/test/** 4 | out/**/*.map 5 | src/** 6 | static/static.png 7 | .gitignore 8 | tsconfig.json 9 | vsc-extension-quickstart.md 10 | tslint.json -------------------------------------------------------------------------------- /vscode_sh_template/SH.tbnf: -------------------------------------------------------------------------------- 1 | extern var SH : (token, str) -> int 2 | 3 | LINE_END = "\n" | "\r"; 4 | DIGIT = [0-9]; 5 | INT = DIGIT+ ; 6 | VERSION = "v" INT ("." INT ("." INT)?)?; 7 | FLT = INT ("." INT)? ; 8 | EXP = "-"? FLT (("e" | "E") INT)?; 9 | STR = "\"" ( "\\" _ | ! "\"" )* "\"" ; 10 | SPACE = ("\t" | "\n" | "\r" | " ")+; 11 | LINE_COMMENT = "-" "-" (!("\n" | "\r"))*; 12 | ID_CHAR = ([a-z] | [A-Z] | "_" | [\u4e00-\u9fa5]); 13 | ID = ID_CHAR (ID_CHAR | [0-9] | "-")*; 14 | 15 | ignore SPACE 16 | 17 | start : "format" version component { SH($1, "namespace") } 18 | list(a) : a { 0 } 19 | | list(a) a { 0 } 20 | 21 | 22 | 23 | op : "==" { SH($1, "operator") } 24 | | "!=" { SH($1, "operator") } 25 | | ">" { SH($1, "operator") } 26 | | "<" { SH($1, "operator") } 27 | | ">=" { SH($1, "operator") } 28 | | "<=" { SH($1, "operator") } 29 | | "~" { SH($1, "operator") } 30 | | "^" { SH($1, "operator") } 31 | 32 | version : { SH($1, "regexp") } 33 | specifier : op version { 0 } 34 | specifier_set : specifier { 0 } 35 | | specifier_set "&&" specifier { SH($2, "enum") } 36 | 37 | comment : { SH($1, "comment") } 38 | 39 | id : "format" { SH($1, "variable") } 40 | | { SH($1, "variable") } 41 | 42 | comp : { SH($1, "number") } 43 | | { SH($1, "string") } 44 | | "true" { SH($1, "struct") } 45 | | "false" { SH($1, "struct") } 46 | | "null" { SH($1, "struct") } 47 | | version { 0 } 48 | | specifier_set { 0 } 49 | | id comp { 0 } 50 | | "{" list(component) "}" 51 | { SH($1, "class"); SH($3, "class") } 52 | | "{" "}" { SH($1, "class"); SH($2, "class") } 53 | 54 | 55 | component : comp { 0 } 56 | | list(comment) comp { 0 } 57 | -------------------------------------------------------------------------------- /vscode_sh_template/language-configuration.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "comments": { 4 | "lineComment": "--" 5 | }, 6 | "brackets": [ 7 | ["{", "}"], 8 | ], 9 | "surroundingPairs": [ 10 | ["{", "}"], 11 | ["'", "'"] 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /vscode_sh_template/out/SHLexer.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"SHLexer.js","sourceRoot":"","sources":["../src/SHLexer.ts"],"names":[],"mappings":"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"} -------------------------------------------------------------------------------- /vscode_sh_template/out/SHListener.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // Generated from .\src\SH.g4 by ANTLR 4.9.0-SNAPSHOT 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | //# sourceMappingURL=SHListener.js.map -------------------------------------------------------------------------------- /vscode_sh_template/out/SHListener.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"SHListener.js","sourceRoot":"","sources":["../src/SHListener.ts"],"names":[],"mappings":";AAAA,qDAAqD"} -------------------------------------------------------------------------------- /vscode_sh_template/out/SH_require.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.clearCache = exports.getCache = exports.isKeyword = exports.isLiteral = exports.isString = exports.isAttr = exports.isVariable = exports.isNumber = exports.isBinaryOperator = exports.isUnaryOperator = exports.isFuncCall = exports.isFuncDecl = exports.isControl = exports.SH = exports.tokenModifiersLegend = exports.tokenTypesLegend = void 0; 4 | exports.tokenTypesLegend = [ 5 | 'comment', 6 | 'string', 7 | 'keyword', 8 | 'number', 9 | 'regexp', 10 | 'operator', 11 | 'namespace', 12 | 'type', 13 | 'struct', 14 | 'class', 15 | 'interface', 16 | 'enum', 17 | 'typeParameter', 18 | 'function', 19 | 'method', 20 | 'decorator', 21 | 'macro', 22 | 'variable', 23 | 'parameter', 24 | 'property', 25 | 'label' 26 | ]; 27 | function getNativeTokenId(s) { 28 | return exports.tokenTypesLegend.indexOf(s); 29 | } 30 | class Scope { 31 | } 32 | Scope.Keyword = getNativeTokenId("keyword"); 33 | Scope.Number = getNativeTokenId("number"); 34 | Scope.String = getNativeTokenId("string"); 35 | Scope.Operator = getNativeTokenId("operator"); 36 | Scope.Namespace = getNativeTokenId("namespace"); 37 | Scope.Function = getNativeTokenId("function"); 38 | Scope.Variable = getNativeTokenId("variable"); 39 | Scope.Label = getNativeTokenId("label"); 40 | Scope.Property = getNativeTokenId("property"); 41 | Scope.Method = getNativeTokenId("method"); 42 | Scope.Interface = getNativeTokenId("interface"); 43 | Scope.Struct = getNativeTokenId("struct"); 44 | exports.tokenModifiersLegend = [ 45 | 'declaration', 46 | 'documentation', 47 | 'readonly', 48 | 'static', 49 | 'abstract', 50 | 'deprecated', 51 | 'modification', 52 | 'async' 53 | ]; 54 | let render_cache = new Array(); 55 | function SH(x, scope) { 56 | render_cache.push([getNativeTokenId(scope), x]); 57 | return 0; 58 | } 59 | exports.SH = SH; 60 | function isControl(x) { 61 | render_cache.push([Scope.Label, x]); 62 | return 0; 63 | } 64 | exports.isControl = isControl; 65 | function isFuncDecl(x) { 66 | render_cache.push([Scope.Interface, x]); 67 | return 0; 68 | } 69 | exports.isFuncDecl = isFuncDecl; 70 | function isFuncCall(x) { 71 | render_cache.push([Scope.Method, x]); 72 | return 0; 73 | } 74 | exports.isFuncCall = isFuncCall; 75 | function isUnaryOperator(x) { 76 | render_cache.push([Scope.Namespace, x]); 77 | return 0; 78 | } 79 | exports.isUnaryOperator = isUnaryOperator; 80 | function isBinaryOperator(x) { 81 | render_cache.push([Scope.Operator, x]); 82 | return 0; 83 | } 84 | exports.isBinaryOperator = isBinaryOperator; 85 | function isNumber(x) { 86 | render_cache.push([Scope.Number, x]); 87 | return 0; 88 | } 89 | exports.isNumber = isNumber; 90 | function isVariable(x) { 91 | render_cache.push([Scope.Variable, x]); 92 | return 0; 93 | } 94 | exports.isVariable = isVariable; 95 | function isAttr(x) { 96 | render_cache.push([Scope.Property, x]); 97 | return 0; 98 | } 99 | exports.isAttr = isAttr; 100 | function isString(x) { 101 | render_cache.push([Scope.String, x]); 102 | return 0; 103 | } 104 | exports.isString = isString; 105 | function isLiteral(x) { 106 | render_cache.push([Scope.Struct, x]); 107 | return 0; 108 | } 109 | exports.isLiteral = isLiteral; 110 | function isKeyword(x) { 111 | render_cache.push([Scope.Keyword, x]); 112 | return 0; 113 | } 114 | exports.isKeyword = isKeyword; 115 | function getCache() { 116 | return render_cache; 117 | } 118 | exports.getCache = getCache; 119 | function clearCache() { 120 | render_cache = []; 121 | } 122 | exports.clearCache = clearCache; 123 | //# sourceMappingURL=SH_require.js.map -------------------------------------------------------------------------------- /vscode_sh_template/out/SH_require.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"SH_require.js","sourceRoot":"","sources":["../src/SH_require.ts"],"names":[],"mappings":"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"} -------------------------------------------------------------------------------- /vscode_sh_template/out/SHprovider.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.DocumentSemanticTokensProvider = exports.render_text = exports.legend = void 0; 4 | const vscode = require("vscode"); 5 | const antlr = require("antlr4ts"); 6 | const sh = require("./SH_require"); 7 | const sh_parser = require("./SHParser"); 8 | const sh_lexer = require("./SHLexer"); 9 | const antlr4ts_1 = require("antlr4ts"); 10 | exports.legend = new vscode.SemanticTokensLegend(sh.tokenTypesLegend, sh.tokenModifiersLegend); 11 | let setErr = undefined; 12 | let errorItem = undefined; 13 | class VSCodeErrorListener { 14 | syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) { 15 | setErr = vscode.window.showInformationMessage(msg); 16 | } 17 | } 18 | function render_text(text) { 19 | const inputStream = antlr.CharStreams.fromString(text); 20 | const lexer = new sh_lexer.SHLexer(inputStream); 21 | const tokenStream = new antlr4ts_1.CommonTokenStream(lexer); 22 | const parser = new sh_parser.SHParser(tokenStream); 23 | parser.addErrorListener(new VSCodeErrorListener()); 24 | parser.start(); 25 | } 26 | exports.render_text = render_text; 27 | function anyStr(value) { 28 | return value.toString(); 29 | } 30 | async function taskError() { 31 | if (setErr !== undefined) { 32 | errorItem = await setErr; 33 | setErr = undefined; 34 | } 35 | else { 36 | if (errorItem !== undefined) { 37 | try { 38 | errorItem.title = ""; 39 | } 40 | catch { } 41 | errorItem = undefined; 42 | } 43 | } 44 | } 45 | class DocumentSemanticTokensProvider { 46 | async provideDocumentSemanticTokens(document, _) { 47 | sh.clearCache(); 48 | let cache = sh.getCache(); 49 | try { 50 | render_text(document.getText()); 51 | } 52 | catch { } 53 | const builder = new vscode.SemanticTokensBuilder(); 54 | for (let [scope, token] of cache) { 55 | builder.push(token.line - 1, token.charPositionInLine, token.stopIndex - token.startIndex + 1, scope, 0); 56 | } 57 | taskError(); 58 | return builder.build(); 59 | } 60 | } 61 | exports.DocumentSemanticTokensProvider = DocumentSemanticTokensProvider; 62 | //# sourceMappingURL=SHprovider.js.map -------------------------------------------------------------------------------- /vscode_sh_template/out/SHprovider.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"SHprovider.js","sourceRoot":"","sources":["../src/SHprovider.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,kCAAiC;AACjC,mCAAkC;AAClC,wCAAuC;AACvC,sCAAqC;AAErC,uCAA4C;AAE/B,QAAA,MAAM,GAAG,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAAE,CAAC,gBAAgB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;AAEpG,IAAI,MAAM,GAAyD,SAAS,CAAA;AAC5E,IAAI,SAAS,GAAoC,SAAS,CAAA;AAE1D,MAAM,mBAAmB;IACrB,WAAW,CAAC,UAAsC,EAAE,eAAoB,EAAE,IAAY,EAAE,kBAA0B,EAAE,GAAW,EAAE,CAAyC;QAEtK,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAqB,GAAG,CAAC,CAAC;IAC3E,CAAC;CACJ;AAED,SAAgB,WAAW,CAAC,IAAY;IACvC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,IAAI,4BAAiB,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,CAAC,gBAAgB,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC;IACnD,MAAM,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC;AAPD,kCAOC;AAED,SAAS,MAAM,CAAC,KAAU;IACtB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAGD,KAAK,UAAU,SAAS;IAEpB,IAAI,MAAM,KAAK,SAAS,EACxB;QACI,SAAS,GAAG,MAAM,MAAM,CAAC;QACzB,MAAM,GAAG,SAAS,CAAA;KACrB;SAED;QACI,IAAI,SAAS,KAAK,SAAS,EAC3B;YACI,IACA;gBAAE,SAAS,CAAC,KAAK,GAAG,EAAE,CAAC;aAAE;YACzB,MAAM,GAAG;YACT,SAAS,GAAG,SAAS,CAAA;SACxB;KACJ;AACL,CAAC;AAED,MAAa,8BAA8B;IAC1C,KAAK,CAAC,6BAA6B,CAAC,QAA6B,EAAE,CAA2B;QAC7F,EAAE,CAAC,UAAU,EAAE,CAAC;QACV,IAAI,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;QACzB,IACA;YACI,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;SACnC;QACD,MAAK,GAAG;QAGR,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACzD,KAAI,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,EACzB;YACI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,SAAS,GAAC,KAAK,CAAC,UAAU,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;SAC1G;QAEP,SAAS,EAAE,CAAC;QACN,OAAO,OAAO,CAAC,KAAK,EAAE,CAAA;IAC7B,CAAC;CACD;AApBD,wEAoBC"} -------------------------------------------------------------------------------- /vscode_sh_template/out/SHrequire.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.clearCache = exports.getCache = exports.isKeyword = exports.isLiteral = exports.isString = exports.isAttr = exports.isVariable = exports.isNumber = exports.isBinaryOperator = exports.isUnaryOperator = exports.isFuncCall = exports.isFuncDecl = exports.isControl = exports.Highlight = exports.tokenModifiersLegend = exports.tokenTypesLegend = void 0; 4 | exports.tokenTypesLegend = [ 5 | 'comment', 6 | 'string', 7 | 'keyword', 8 | 'number', 9 | 'regexp', 10 | 'operator', 11 | 'namespace', 12 | 'type', 13 | 'struct', 14 | 'class', 15 | 'interface', 16 | 'enum', 17 | 'typeParameter', 18 | 'function', 19 | 'method', 20 | 'decorator', 21 | 'macro', 22 | 'variable', 23 | 'parameter', 24 | 'property', 25 | 'label' 26 | ]; 27 | function getNativeTokenId(s) { 28 | return exports.tokenTypesLegend.indexOf(s); 29 | } 30 | class Scope { 31 | } 32 | Scope.Keyword = getNativeTokenId("keyword"); 33 | Scope.Number = getNativeTokenId("number"); 34 | Scope.String = getNativeTokenId("string"); 35 | Scope.Operator = getNativeTokenId("operator"); 36 | Scope.Namespace = getNativeTokenId("namespace"); 37 | Scope.Function = getNativeTokenId("function"); 38 | Scope.Variable = getNativeTokenId("variable"); 39 | Scope.Label = getNativeTokenId("label"); 40 | Scope.Property = getNativeTokenId("property"); 41 | Scope.Method = getNativeTokenId("method"); 42 | Scope.Interface = getNativeTokenId("interface"); 43 | Scope.Struct = getNativeTokenId("struct"); 44 | exports.tokenModifiersLegend = [ 45 | 'declaration', 46 | 'documentation', 47 | 'readonly', 48 | 'static', 49 | 'abstract', 50 | 'deprecated', 51 | 'modification', 52 | 'async' 53 | ]; 54 | let render_cache = new Array(); 55 | function Highlight(x, scope) { 56 | render_cache.push([getNativeTokenId(scope), x]); 57 | return 0; 58 | } 59 | exports.Highlight = Highlight; 60 | function isControl(x) { 61 | render_cache.push([Scope.Label, x]); 62 | return 0; 63 | } 64 | exports.isControl = isControl; 65 | function isFuncDecl(x) { 66 | render_cache.push([Scope.Interface, x]); 67 | return 0; 68 | } 69 | exports.isFuncDecl = isFuncDecl; 70 | function isFuncCall(x) { 71 | render_cache.push([Scope.Method, x]); 72 | return 0; 73 | } 74 | exports.isFuncCall = isFuncCall; 75 | function isUnaryOperator(x) { 76 | render_cache.push([Scope.Namespace, x]); 77 | return 0; 78 | } 79 | exports.isUnaryOperator = isUnaryOperator; 80 | function isBinaryOperator(x) { 81 | render_cache.push([Scope.Operator, x]); 82 | return 0; 83 | } 84 | exports.isBinaryOperator = isBinaryOperator; 85 | function isNumber(x) { 86 | render_cache.push([Scope.Number, x]); 87 | return 0; 88 | } 89 | exports.isNumber = isNumber; 90 | function isVariable(x) { 91 | render_cache.push([Scope.Variable, x]); 92 | return 0; 93 | } 94 | exports.isVariable = isVariable; 95 | function isAttr(x) { 96 | render_cache.push([Scope.Property, x]); 97 | return 0; 98 | } 99 | exports.isAttr = isAttr; 100 | function isString(x) { 101 | render_cache.push([Scope.String, x]); 102 | return 0; 103 | } 104 | exports.isString = isString; 105 | function isLiteral(x) { 106 | render_cache.push([Scope.Struct, x]); 107 | return 0; 108 | } 109 | exports.isLiteral = isLiteral; 110 | function isKeyword(x) { 111 | render_cache.push([Scope.Keyword, x]); 112 | return 0; 113 | } 114 | exports.isKeyword = isKeyword; 115 | function getCache() { 116 | return render_cache; 117 | } 118 | exports.getCache = getCache; 119 | function clearCache() { 120 | render_cache = []; 121 | } 122 | exports.clearCache = clearCache; 123 | //# sourceMappingURL=SHrequire.js.map -------------------------------------------------------------------------------- /vscode_sh_template/out/SHrequire.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"SHrequire.js","sourceRoot":"","sources":["../src/SHrequire.ts"],"names":[],"mappings":"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"} -------------------------------------------------------------------------------- /vscode_sh_template/out/extension.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.activate = void 0; 4 | const vscode = require("vscode"); 5 | const SHprovider_1 = require("./SHprovider"); 6 | function activate(context) { 7 | context.subscriptions.push(vscode.languages.registerDocumentSemanticTokensProvider({ scheme: 'file', language: 'comf' }, new SHprovider_1.DocumentSemanticTokensProvider(), SHprovider_1.legend)); 8 | } 9 | exports.activate = activate; 10 | //# sourceMappingURL=extension.js.map -------------------------------------------------------------------------------- /vscode_sh_template/out/extension.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,6CAAsE;AAEtE,SAAgB,QAAQ,CAAC,OAAgC;IACrD,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,sCAAsC,CAC9E,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EACpC,IAAI,2CAA8B,EAAE,EAAE,mBAAM,CAAC,CAAC,CAAC;AACvD,CAAC;AAJD,4BAIC"} -------------------------------------------------------------------------------- /vscode_sh_template/out/lua_shListener.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // Generated from .\lua_sh.g4 by ANTLR 4.9.0-SNAPSHOT 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | //# sourceMappingURL=lua_shListener.js.map -------------------------------------------------------------------------------- /vscode_sh_template/out/lua_shListener.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lua_shListener.js","sourceRoot":"","sources":["../src/lua_shListener.ts"],"names":[],"mappings":";AAAA,qDAAqD"} -------------------------------------------------------------------------------- /vscode_sh_template/out/lua_sh_provider.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.DocumentSemanticTokensProvider = exports.render_text = exports.legend = void 0; 4 | const vscode = require("vscode"); 5 | const antlr = require("antlr4ts"); 6 | const sh = require("./lua_sh_require"); 7 | const lua_parser = require("./lua_shParser"); 8 | const lua_lexer = require("./lua_shLexer"); 9 | const antlr4ts_1 = require("antlr4ts"); 10 | exports.legend = new vscode.SemanticTokensLegend(sh.tokenTypesLegend, sh.tokenModifiersLegend); 11 | function render_text(text) { 12 | const inputStream = antlr.CharStreams.fromString(text); 13 | const lexer = new lua_lexer.lua_shLexer(inputStream); 14 | const tokenStram = new antlr4ts_1.CommonTokenStream(lexer); 15 | const parser = new lua_parser.lua_shParser(tokenStram); 16 | parser.start(); 17 | } 18 | exports.render_text = render_text; 19 | class DocumentSemanticTokensProvider { 20 | async provideDocumentSemanticTokens(document, _) { 21 | sh.clearCache(); 22 | let cache = sh.getCache(); 23 | render_text(document.getText()); 24 | const builder = new vscode.SemanticTokensBuilder(); 25 | for (let [scope, token] of cache) { 26 | builder.push(token.line - 1, token.charPositionInLine, token.stopIndex - token.startIndex + 1, scope, 0); 27 | } 28 | return builder.build(); 29 | } 30 | } 31 | exports.DocumentSemanticTokensProvider = DocumentSemanticTokensProvider; 32 | //# sourceMappingURL=lua_sh_provider.js.map -------------------------------------------------------------------------------- /vscode_sh_template/out/lua_sh_provider.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lua_sh_provider.js","sourceRoot":"","sources":["../src/lua_sh_provider.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,kCAAiC;AACjC,uCAAsC;AACtC,6CAA4C;AAC5C,2CAA0C;AAE1C,uCAA4C;AAE/B,QAAA,MAAM,GAAG,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAAE,CAAC,gBAAgB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;AAGpG,SAAgB,WAAW,CAAC,IAAY;IACvC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,IAAI,4BAAiB,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC;AAND,kCAMC;AAGD,MAAa,8BAA8B;IAC1C,KAAK,CAAC,6BAA6B,CAAC,QAA6B,EAAE,CAA2B;QAC7F,EAAE,CAAC,UAAU,EAAE,CAAC;QACV,IAAI,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;QACzB,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACzD,KAAI,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,EACzB;YACI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,SAAS,GAAC,KAAK,CAAC,UAAU,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;SAC1G;QACP,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACD;AAZD,wEAYC"} -------------------------------------------------------------------------------- /vscode_sh_template/out/lua_sh_require.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.clearCache = exports.getCache = exports.isKeyword = exports.isLiteral = exports.isString = exports.isAttr = exports.isVariable = exports.isNumber = exports.isBinaryOperator = exports.isUnaryOperator = exports.isFuncCall = exports.isFuncDecl = exports.isControl = exports.tokenModifiersLegend = exports.tokenTypesLegend = void 0; 4 | exports.tokenTypesLegend = [ 5 | 'comment', 6 | 'string', 7 | 'keyword', 8 | 'number', 9 | 'regexp', 10 | 'operator', 11 | 'namespace', 12 | 'type', 13 | 'struct', 14 | 'class', 15 | 'interface', 16 | 'enum', 17 | 'typeParameter', 18 | 'function', 19 | 'method', 20 | 'decorator', 21 | 'macro', 22 | 'variable', 23 | 'parameter', 24 | 'property', 25 | 'label' 26 | ]; 27 | function getNativeTokenId(s) { 28 | return exports.tokenTypesLegend.indexOf(s); 29 | } 30 | class Scope { 31 | } 32 | Scope.Keyword = getNativeTokenId("keyword"); 33 | Scope.Number = getNativeTokenId("number"); 34 | Scope.String = getNativeTokenId("string"); 35 | Scope.Operator = getNativeTokenId("operator"); 36 | Scope.Namespace = getNativeTokenId("namespace"); 37 | Scope.Function = getNativeTokenId("function"); 38 | Scope.Variable = getNativeTokenId("variable"); 39 | Scope.Label = getNativeTokenId("label"); 40 | Scope.Property = getNativeTokenId("property"); 41 | Scope.Method = getNativeTokenId("method"); 42 | Scope.Interface = getNativeTokenId("interface"); 43 | Scope.Struct = getNativeTokenId("struct"); 44 | exports.tokenModifiersLegend = [ 45 | 'declaration', 46 | 'documentation', 47 | 'readonly', 48 | 'static', 49 | 'abstract', 50 | 'deprecated', 51 | 'modification', 52 | 'async' 53 | ]; 54 | let render_cache = new Array(); 55 | function isControl(x) { 56 | render_cache.push([Scope.Label, x]); 57 | return 0; 58 | } 59 | exports.isControl = isControl; 60 | function isFuncDecl(x) { 61 | render_cache.push([Scope.Interface, x]); 62 | return 0; 63 | } 64 | exports.isFuncDecl = isFuncDecl; 65 | function isFuncCall(x) { 66 | render_cache.push([Scope.Method, x]); 67 | return 0; 68 | } 69 | exports.isFuncCall = isFuncCall; 70 | function isUnaryOperator(x) { 71 | render_cache.push([Scope.Namespace, x]); 72 | return 0; 73 | } 74 | exports.isUnaryOperator = isUnaryOperator; 75 | function isBinaryOperator(x) { 76 | render_cache.push([Scope.Operator, x]); 77 | return 0; 78 | } 79 | exports.isBinaryOperator = isBinaryOperator; 80 | function isNumber(x) { 81 | render_cache.push([Scope.Number, x]); 82 | return 0; 83 | } 84 | exports.isNumber = isNumber; 85 | function isVariable(x) { 86 | render_cache.push([Scope.Variable, x]); 87 | return 0; 88 | } 89 | exports.isVariable = isVariable; 90 | function isAttr(x) { 91 | render_cache.push([Scope.Property, x]); 92 | return 0; 93 | } 94 | exports.isAttr = isAttr; 95 | function isString(x) { 96 | render_cache.push([Scope.String, x]); 97 | return 0; 98 | } 99 | exports.isString = isString; 100 | function isLiteral(x) { 101 | render_cache.push([Scope.Struct, x]); 102 | return 0; 103 | } 104 | exports.isLiteral = isLiteral; 105 | function isKeyword(x) { 106 | render_cache.push([Scope.Keyword, x]); 107 | return 0; 108 | } 109 | exports.isKeyword = isKeyword; 110 | function getCache() { 111 | return render_cache; 112 | } 113 | exports.getCache = getCache; 114 | function clearCache() { 115 | render_cache = []; 116 | } 117 | exports.clearCache = clearCache; 118 | //# sourceMappingURL=lua_sh_require.js.map -------------------------------------------------------------------------------- /vscode_sh_template/out/lua_sh_require.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"lua_sh_require.js","sourceRoot":"","sources":["../src/lua_sh_require.ts"],"names":[],"mappings":"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"} -------------------------------------------------------------------------------- /vscode_sh_template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-tbnf-lua", 3 | "displayName": "vscode-tbnf-lua", 4 | "description": "example", 5 | "version": "0.0.1", 6 | "publisher": "GReSummer", 7 | "private": true, 8 | "license": "MIT", 9 | "icon": "static/icon.png", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/thautwarm/cross-editor-syntax-highlighter/backend-vscode" 13 | }, 14 | "engines": { 15 | "vscode": "^1.42.0" 16 | }, 17 | "categories": [ 18 | "Other" 19 | ], 20 | "activationEvents": [ 21 | "onLanguage:comf" 22 | ], 23 | "main": "./out/extension.js", 24 | "contributes": { 25 | "languages": [ 26 | { 27 | "id": "comf", 28 | "extensions": [ 29 | ".comf" 30 | ], 31 | "configuration": "./language-configuration.json" 32 | } 33 | ] 34 | }, 35 | "scripts": { 36 | "vscode:prepublish": "npm run compile", 37 | "compile": "tsc -p ./", 38 | "antlr4ts": "antlr4ts -visitor src/lua_sh.g4", 39 | "lint": "eslint . --ext .ts,.tsx", 40 | "watch": "tsc -watch -p ./" 41 | }, 42 | "devDependencies": { 43 | "@types/node": "^12.12.0", 44 | "@types/vscode": "^1.42.0", 45 | "@typescript-eslint/eslint-plugin": "^4.16.0", 46 | "@typescript-eslint/parser": "^4.16.0", 47 | "antlr4ts-cli": "^0.5.0-alpha.4", 48 | "eslint": "^7.21.0", 49 | "typescript": "^4.4.3" 50 | }, 51 | "dependencies": { 52 | "antlr4ts": "^0.5.0-alpha.4" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vscode_sh_template/src/SH.g4: -------------------------------------------------------------------------------- 1 | grammar SH; 2 | @header { 3 | import { SH } from "./SH_require" 4 | } 5 | start returns [result: number]: v=start__y_ EOF { $result = _localctx._v.result; }; 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | start__y_ returns [number result] 18 | : start__y__0__1='format' version component { 19 | $result = SH( _localctx._start__y__0__1, "namespace"); 20 | } 21 | ; 22 | op returns [number result] 23 | : op_0__1='==' { 24 | $result = SH( _localctx._op_0__1, "operator"); 25 | } 26 | | op_1__1='!=' { 27 | $result = SH( _localctx._op_1__1, "operator"); 28 | } 29 | | op_2__1='>' { 30 | $result = SH( _localctx._op_2__1, "operator"); 31 | } 32 | | op_3__1='<' { 33 | $result = SH( _localctx._op_3__1, "operator"); 34 | } 35 | | op_4__1='>=' { 36 | $result = SH( _localctx._op_4__1, "operator"); 37 | } 38 | | op_5__1='<=' { 39 | $result = SH( _localctx._op_5__1, "operator"); 40 | } 41 | | op_6__1='~' { 42 | $result = SH( _localctx._op_6__1, "operator"); 43 | } 44 | | op_7__1='^' { 45 | $result = SH( _localctx._op_7__1, "operator"); 46 | } 47 | ; 48 | version returns [number result] 49 | : version_0__1=VERSION { 50 | $result = SH( _localctx._version_0__1, "regexp"); 51 | } 52 | ; 53 | specifier returns [number result] 54 | : op version { 55 | $result = 0; 56 | } 57 | ; 58 | specifier_set returns [number result] 59 | : specifier { 60 | $result = 0; 61 | } 62 | | specifier_set specifier_set_1__2='&&' specifier { 63 | $result = SH( _localctx._specifier_set_1__2, "enum"); 64 | } 65 | ; 66 | comment returns [number result] 67 | : comment_0__1=LINE_COMMENT { 68 | $result = SH( _localctx._comment_0__1, "comment"); 69 | } 70 | ; 71 | id returns [number result] 72 | : id_0__1='format' { 73 | $result = SH( _localctx._id_0__1, "variable"); 74 | } 75 | | id_1__1=ID { 76 | $result = SH( _localctx._id_1__1, "variable"); 77 | } 78 | ; 79 | list_o_component_p_ returns [number result] 80 | : component { 81 | $result = 0; 82 | } 83 | | list_o_component_p_ component { 84 | $result = 0; 85 | } 86 | ; 87 | comp returns [number result] 88 | : comp_0__1=EXP { 89 | $result = SH( _localctx._comp_0__1, "number"); 90 | } 91 | | comp_1__1=STR { 92 | $result = SH( _localctx._comp_1__1, "string"); 93 | } 94 | | comp_2__1='true' { 95 | $result = SH( _localctx._comp_2__1, "struct"); 96 | } 97 | | comp_3__1='false' { 98 | $result = SH( _localctx._comp_3__1, "struct"); 99 | } 100 | | comp_4__1='null' { 101 | $result = SH( _localctx._comp_4__1, "struct"); 102 | } 103 | | version { 104 | $result = 0; 105 | } 106 | | specifier_set { 107 | $result = 0; 108 | } 109 | | id comp { 110 | $result = 0; 111 | } 112 | | comp_8__1='{' list_o_component_p_ comp_8__3='}' { 113 | let _ : number = SH( _localctx._comp_8__1, "class"); 114 | $result = SH( _localctx._comp_8__3, "class"); 115 | } 116 | | comp_9__1='{' comp_9__2='}' { 117 | let ___98_ : number = SH( _localctx._comp_9__1, "class"); 118 | $result = SH( _localctx._comp_9__2, "class"); 119 | } 120 | ; 121 | list_o_comment_p_ returns [number result] 122 | : comment { 123 | $result = 0; 124 | } 125 | | list_o_comment_p_ comment { 126 | $result = 0; 127 | } 128 | ; 129 | component returns [number result] 130 | : comp { 131 | $result = 0; 132 | } 133 | | list_o_comment_p_ comp { 134 | $result = 0; 135 | } 136 | ; 137 | fragment LINE_END : ('\n' | '\r') ; 138 | fragment DIGIT : [\u0030-\u0039] ; 139 | fragment INT : DIGIT+ ; 140 | VERSION : 'v' INT ('.' INT ('.' INT)?)? ; 141 | fragment FLT : INT ('.' INT)? ; 142 | EXP : '-'? FLT (('e' | 'E') INT)? ; 143 | STR : '"' (('\\' .) | ~'"')* '"' ; 144 | SPACE : ('\t' | '\n' | '\r' | ' ')+ -> channel(HIDDEN); 145 | LINE_COMMENT : '-' '-' ~('\n' | '\r')* ; 146 | fragment ID_CHAR : ([\u0061-\u007A] | [\u0041-\u005A] | '_' | [\u4E00-\u9FA5]) ; 147 | ID : ID_CHAR (ID_CHAR | [\u0030-\u0039] | '-')* ; 148 | -------------------------------------------------------------------------------- /vscode_sh_template/src/SHListener.ts: -------------------------------------------------------------------------------- 1 | // Generated from .\src\SH.g4 by ANTLR 4.9.0-SNAPSHOT 2 | 3 | 4 | import { SH } from "./SH_require" 5 | 6 | 7 | import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener"; 8 | 9 | import { StartContext } from "./SHParser"; 10 | import { Start__y_Context } from "./SHParser"; 11 | import { OpContext } from "./SHParser"; 12 | import { VersionContext } from "./SHParser"; 13 | import { SpecifierContext } from "./SHParser"; 14 | import { Specifier_setContext } from "./SHParser"; 15 | import { CommentContext } from "./SHParser"; 16 | import { IdContext } from "./SHParser"; 17 | import { List_o_component_p_Context } from "./SHParser"; 18 | import { CompContext } from "./SHParser"; 19 | import { List_o_comment_p_Context } from "./SHParser"; 20 | import { ComponentContext } from "./SHParser"; 21 | 22 | 23 | /** 24 | * This interface defines a complete listener for a parse tree produced by 25 | * `SHParser`. 26 | */ 27 | export interface SHListener extends ParseTreeListener { 28 | /** 29 | * Enter a parse tree produced by `SHParser.start`. 30 | * @param ctx the parse tree 31 | */ 32 | enterStart?: (ctx: StartContext) => void; 33 | /** 34 | * Exit a parse tree produced by `SHParser.start`. 35 | * @param ctx the parse tree 36 | */ 37 | exitStart?: (ctx: StartContext) => void; 38 | 39 | /** 40 | * Enter a parse tree produced by `SHParser.start__y_`. 41 | * @param ctx the parse tree 42 | */ 43 | enterStart__y_?: (ctx: Start__y_Context) => void; 44 | /** 45 | * Exit a parse tree produced by `SHParser.start__y_`. 46 | * @param ctx the parse tree 47 | */ 48 | exitStart__y_?: (ctx: Start__y_Context) => void; 49 | 50 | /** 51 | * Enter a parse tree produced by `SHParser.op`. 52 | * @param ctx the parse tree 53 | */ 54 | enterOp?: (ctx: OpContext) => void; 55 | /** 56 | * Exit a parse tree produced by `SHParser.op`. 57 | * @param ctx the parse tree 58 | */ 59 | exitOp?: (ctx: OpContext) => void; 60 | 61 | /** 62 | * Enter a parse tree produced by `SHParser.version`. 63 | * @param ctx the parse tree 64 | */ 65 | enterVersion?: (ctx: VersionContext) => void; 66 | /** 67 | * Exit a parse tree produced by `SHParser.version`. 68 | * @param ctx the parse tree 69 | */ 70 | exitVersion?: (ctx: VersionContext) => void; 71 | 72 | /** 73 | * Enter a parse tree produced by `SHParser.specifier`. 74 | * @param ctx the parse tree 75 | */ 76 | enterSpecifier?: (ctx: SpecifierContext) => void; 77 | /** 78 | * Exit a parse tree produced by `SHParser.specifier`. 79 | * @param ctx the parse tree 80 | */ 81 | exitSpecifier?: (ctx: SpecifierContext) => void; 82 | 83 | /** 84 | * Enter a parse tree produced by `SHParser.specifier_set`. 85 | * @param ctx the parse tree 86 | */ 87 | enterSpecifier_set?: (ctx: Specifier_setContext) => void; 88 | /** 89 | * Exit a parse tree produced by `SHParser.specifier_set`. 90 | * @param ctx the parse tree 91 | */ 92 | exitSpecifier_set?: (ctx: Specifier_setContext) => void; 93 | 94 | /** 95 | * Enter a parse tree produced by `SHParser.comment`. 96 | * @param ctx the parse tree 97 | */ 98 | enterComment?: (ctx: CommentContext) => void; 99 | /** 100 | * Exit a parse tree produced by `SHParser.comment`. 101 | * @param ctx the parse tree 102 | */ 103 | exitComment?: (ctx: CommentContext) => void; 104 | 105 | /** 106 | * Enter a parse tree produced by `SHParser.id`. 107 | * @param ctx the parse tree 108 | */ 109 | enterId?: (ctx: IdContext) => void; 110 | /** 111 | * Exit a parse tree produced by `SHParser.id`. 112 | * @param ctx the parse tree 113 | */ 114 | exitId?: (ctx: IdContext) => void; 115 | 116 | /** 117 | * Enter a parse tree produced by `SHParser.list_o_component_p_`. 118 | * @param ctx the parse tree 119 | */ 120 | enterList_o_component_p_?: (ctx: List_o_component_p_Context) => void; 121 | /** 122 | * Exit a parse tree produced by `SHParser.list_o_component_p_`. 123 | * @param ctx the parse tree 124 | */ 125 | exitList_o_component_p_?: (ctx: List_o_component_p_Context) => void; 126 | 127 | /** 128 | * Enter a parse tree produced by `SHParser.comp`. 129 | * @param ctx the parse tree 130 | */ 131 | enterComp?: (ctx: CompContext) => void; 132 | /** 133 | * Exit a parse tree produced by `SHParser.comp`. 134 | * @param ctx the parse tree 135 | */ 136 | exitComp?: (ctx: CompContext) => void; 137 | 138 | /** 139 | * Enter a parse tree produced by `SHParser.list_o_comment_p_`. 140 | * @param ctx the parse tree 141 | */ 142 | enterList_o_comment_p_?: (ctx: List_o_comment_p_Context) => void; 143 | /** 144 | * Exit a parse tree produced by `SHParser.list_o_comment_p_`. 145 | * @param ctx the parse tree 146 | */ 147 | exitList_o_comment_p_?: (ctx: List_o_comment_p_Context) => void; 148 | 149 | /** 150 | * Enter a parse tree produced by `SHParser.component`. 151 | * @param ctx the parse tree 152 | */ 153 | enterComponent?: (ctx: ComponentContext) => void; 154 | /** 155 | * Exit a parse tree produced by `SHParser.component`. 156 | * @param ctx the parse tree 157 | */ 158 | exitComponent?: (ctx: ComponentContext) => void; 159 | } 160 | 161 | -------------------------------------------------------------------------------- /vscode_sh_template/src/SH_require.ts: -------------------------------------------------------------------------------- 1 | import * as antlr from 'antlr4ts' 2 | 3 | export const tokenTypesLegend = [ 4 | 'comment', 5 | 'string', 6 | 'keyword', 7 | 'number', 8 | 'regexp', 9 | 'operator', 10 | 'namespace', 11 | 'type', 12 | 'struct', 13 | 'class', 14 | 'interface', 15 | 'enum', 16 | 'typeParameter', 17 | 'function', 18 | 'method', 19 | 'decorator', 20 | 'macro', 21 | 'variable', 22 | 'parameter', 23 | 'property', 24 | 'label' 25 | ]; 26 | 27 | function getNativeTokenId(s: string): number { 28 | return tokenTypesLegend.indexOf(s); 29 | } 30 | 31 | class Scope { 32 | public static readonly Keyword = getNativeTokenId("keyword"); 33 | public static readonly Number = getNativeTokenId("number"); 34 | public static readonly String = getNativeTokenId("string"); 35 | public static readonly Operator = getNativeTokenId("operator"); 36 | public static readonly Namespace = getNativeTokenId("namespace"); 37 | public static readonly Function = getNativeTokenId("function"); 38 | public static readonly Variable = getNativeTokenId("variable"); 39 | public static readonly Label = getNativeTokenId("label"); 40 | public static readonly Property = getNativeTokenId("property"); 41 | public static readonly Method = getNativeTokenId("method"); 42 | public static readonly Interface = getNativeTokenId("interface"); 43 | public static readonly Struct = getNativeTokenId("struct"); 44 | 45 | } 46 | 47 | 48 | 49 | 50 | 51 | export const tokenModifiersLegend = [ 52 | 'declaration', 53 | 'documentation', 54 | 'readonly', 55 | 'static', 56 | 'abstract', 57 | 'deprecated', 58 | 'modification', 59 | 'async' 60 | ]; 61 | 62 | type scope = number 63 | let render_cache = new Array<[scope, antlr.Token]>(); 64 | 65 | export function SH(x: antlr.Token, scope: string) { 66 | render_cache.push([getNativeTokenId(scope), x]); 67 | return 0; 68 | } 69 | 70 | export function isControl(x: antlr.Token) { 71 | render_cache.push([Scope.Label, x]); 72 | return 0; 73 | } 74 | 75 | export function isFuncDecl(x: antlr.Token) { 76 | render_cache.push([Scope.Interface, x]); 77 | return 0 78 | } 79 | 80 | export function isFuncCall(x: antlr.Token) { 81 | render_cache.push([Scope.Method, x]); 82 | return 0 83 | } 84 | 85 | export function isUnaryOperator(x: antlr.Token) { 86 | render_cache.push([Scope.Namespace, x]); 87 | return 0 88 | } 89 | 90 | export function isBinaryOperator(x: antlr.Token) { 91 | render_cache.push([Scope.Operator, x]); 92 | return 0 93 | } 94 | 95 | export function isNumber(x: antlr.Token) { 96 | render_cache.push([Scope.Number, x]); 97 | return 0 98 | } 99 | 100 | export function isVariable(x: antlr.Token) { 101 | render_cache.push([Scope.Variable, x]); 102 | return 0 103 | } 104 | 105 | export function isAttr(x: antlr.Token) { 106 | render_cache.push([Scope.Property, x]); 107 | return 0 108 | } 109 | 110 | export function isString(x: antlr.Token) { 111 | render_cache.push([Scope.String, x]); 112 | return 0 113 | } 114 | 115 | export function isLiteral(x: antlr.Token) { 116 | render_cache.push([Scope.Struct, x]); 117 | return 0 118 | } 119 | 120 | export function isKeyword(x: antlr.Token) { 121 | render_cache.push([Scope.Keyword, x]); 122 | return 0 123 | } 124 | 125 | 126 | export function getCache() { 127 | return render_cache; 128 | } 129 | 130 | export function clearCache() { 131 | render_cache = []; 132 | } -------------------------------------------------------------------------------- /vscode_sh_template/src/SHprovider.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode" 2 | import * as antlr from "antlr4ts" 3 | import * as sh from "./SH_require" 4 | import * as sh_parser from "./SHParser" 5 | import * as sh_lexer from "./SHLexer" 6 | 7 | import { CommonTokenStream } from "antlr4ts" 8 | 9 | export const legend = new vscode.SemanticTokensLegend(sh.tokenTypesLegend, sh.tokenModifiersLegend); 10 | 11 | let setErr: Thenable | undefined = undefined 12 | let errorItem : vscode.MessageItem | undefined = undefined 13 | 14 | class VSCodeErrorListener implements antlr.ANTLRErrorListener { 15 | syntaxError(recognizer: antlr.Recognizer, offendingSymbol: any, line: number, charPositionInLine: number, msg: string, e: antlr.RecognitionException | undefined) 16 | { 17 | setErr = vscode.window.showInformationMessage(msg); 18 | } 19 | } 20 | 21 | export function render_text(text: string) { 22 | const inputStream = antlr.CharStreams.fromString(text); 23 | const lexer = new sh_lexer.SHLexer(inputStream); 24 | const tokenStream = new CommonTokenStream(lexer); 25 | const parser = new sh_parser.SHParser(tokenStream); 26 | parser.addErrorListener(new VSCodeErrorListener()); 27 | parser.start(); 28 | } 29 | 30 | function anyStr(value: any): string { 31 | return value.toString(); 32 | } 33 | 34 | 35 | async function taskError() 36 | { 37 | if (setErr !== undefined) 38 | { 39 | errorItem = await setErr; 40 | setErr = undefined 41 | } 42 | else 43 | { 44 | if (errorItem !== undefined) 45 | { 46 | try 47 | { errorItem.title = ""; } 48 | catch { } 49 | errorItem = undefined 50 | } 51 | } 52 | } 53 | 54 | export class DocumentSemanticTokensProvider implements vscode.DocumentSemanticTokensProvider { 55 | async provideDocumentSemanticTokens(document: vscode.TextDocument, _: vscode.CancellationToken): Promise { 56 | sh.clearCache(); 57 | let cache = sh.getCache() 58 | try 59 | { 60 | render_text(document.getText()); 61 | } 62 | catch{ } 63 | 64 | 65 | const builder = new vscode.SemanticTokensBuilder(); 66 | for(let [scope, token] of cache) 67 | { 68 | builder.push(token.line - 1, token.charPositionInLine, token.stopIndex-token.startIndex + 1, scope, 0); 69 | } 70 | 71 | taskError(); 72 | return builder.build() 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /vscode_sh_template/src/extension.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import { DocumentSemanticTokensProvider, legend } from "./SHprovider"; 3 | 4 | export function activate(context: vscode.ExtensionContext) { 5 | context.subscriptions.push(vscode.languages.registerDocumentSemanticTokensProvider( 6 | { scheme: 'file', language: 'comf' }, 7 | new DocumentSemanticTokensProvider(), legend)); 8 | } 9 | -------------------------------------------------------------------------------- /vscode_sh_template/src/rename.tbnf.py: -------------------------------------------------------------------------------- 1 | def rename_type(x): 2 | if x == "int": 3 | return "number" 4 | if x == "float": 5 | return "number" 6 | if x == "token": 7 | return "Token" 8 | if x == "list": 9 | return "Array" 10 | if x == "str": 11 | return "string" 12 | return x -------------------------------------------------------------------------------- /vscode_sh_template/testit.comf: -------------------------------------------------------------------------------- 1 | function f(a, b, ...) 2 | 1 - -g(a, b, c()) 3 | end -------------------------------------------------------------------------------- /vscode_sh_template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "strictPropertyInitialization": false, 5 | "target": "es2019", 6 | "lib": ["ES2019"], 7 | "outDir": "out", 8 | "sourceMap": true, 9 | "rootDir": "src", 10 | "strict": true 11 | }, 12 | "exclude": ["node_modules", ".vscode-test"] 13 | } --------------------------------------------------------------------------------