Skip to content

Commit 6e7f994

Browse files
Add MAP type, map literals, map indexing and map ops; small spec clarifications
Introduce an N-dimensional associative MAP type and its literal syntax <key = value, ...>, including nested maps and angle-bracket indexing m<k1,k2>. Specify insertion-order preservation, sparse/non-rectangular maps, on-demand creation of intermediate nested maps, and static typing of map entries; add DEL(map<k>) for deletion. Add built-in operators SIGNATURE, COPY, DEEPCOPY, KEYS, VALUES, KEYIN, VALUEIN. Rename/document builtin convolution operator from CONVOLVE to CONV. Clarify function signature spacing and tweak identifier character-set examples (removed </> from the listed punctuation).
1 parent bc6bef8 commit 6e7f994

File tree

7 files changed

+695
-102
lines changed

7 files changed

+695
-102
lines changed

SPECIFICATION.html

Lines changed: 34 additions & 6 deletions
Large diffs are not rendered by default.

asm-lang.exe

13.3 KB
Binary file not shown.

asm-lang.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _parse_statements_from_source(text: str, filename: str, *, type_names: Optio
5656

5757
def run_repl(*, verbose: bool, services) -> int:
5858
print("\x1b[38;2;153;221;255mASM-Lang\033[0m REPL. Enter statements, blank line to run buffer.") # "ASM-Lang" in light blue
59-
# Use "<string>" as the REPL's effective source filename so that MAIN() and imports behave
59+
# Use "<repl>" as the REPL's effective source filename so that MAIN() and imports behave
6060
had_output = False
6161
def _output_sink(text: str) -> None:
6262
nonlocal had_output
@@ -89,7 +89,7 @@ def _output_sink(text: str) -> None:
8989
try:
9090
interpreter = Interpreter(
9191
source="",
92-
filename="<string>",
92+
filename="<repl>",
9393
verbose=verbose,
9494
services=services,
9595
input_provider=(lambda: input()),
@@ -130,7 +130,7 @@ def _output_sink(text: str) -> None:
130130

131131
if not buffer and stripped != "" and not is_block_start:
132132
try:
133-
statements = _parse_statements_from_source(line, "<string>", type_names=interpreter.type_registry.names())
133+
statements = _parse_statements_from_source(line, "<repl>", type_names=interpreter.type_registry.names())
134134
try:
135135
interpreter._execute_block(statements, global_env)
136136
except ExitSignal as sig:
@@ -152,7 +152,7 @@ def _output_sink(text: str) -> None:
152152
source_text = "\n".join(buffer)
153153
buffer.clear()
154154
try:
155-
statements = _parse_statements_from_source(source_text, "<string>", type_names=interpreter.type_registry.names())
155+
statements = _parse_statements_from_source(source_text, "<repl>", type_names=interpreter.type_registry.names())
156156
interpreter._execute_block(statements, global_env)
157157
except ExitSignal as sig:
158158
return sig.code
@@ -249,7 +249,7 @@ def run_cli(argv: Optional[List[str]] = None) -> int:
249249

250250
if args.source_mode:
251251
source_text = program
252-
filename = "<string>"
252+
filename = "<repl>"
253253
else:
254254
filename = program
255255
try:

extensions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ def build_default_services() -> RuntimeServices:
400400
services.type_registry.seal("FLT")
401401
services.type_registry.seal("STR")
402402
services.type_registry.seal("TNS")
403+
services.type_registry.seal("MAP")
403404
services.type_registry.seal("FUNC")
404405
return services
405406

0 commit comments

Comments
 (0)