Commit Graph

95 Commits

Author SHA1 Message Date
d746ea5234 lang: ast: fix nullptr deref in expr_finalise_arith when calculating ast node bounds 2025-05-12 15:53:06 +01:00
1d4661f7a4 lang: ast: fix parser_push_diag not setting diag location 2025-05-09 13:38:38 +01:00
b89c3bedc5 lang: ast: add diag for do keyword in inline for-loop 2025-05-08 22:32:23 +01:00
5f560d28a7 lang: ast: update arith parser to set ast node bounds 2025-05-08 22:31:37 +01:00
c12371f0ec lang: ast: add diag support to parser 2025-05-08 22:30:23 +01:00
cbec21b90f lang: implement elif keyword for more complex if-statements 2025-04-24 09:45:26 +01:00
3af786b32c lang: ast: fix selector, unit-package, and unit-import string conversion
stringifying selectors with unnamed args no longer causes a segfault,
and unit-package and unit-import node strings are now formatted correctly.
2025-04-23 10:58:22 +01:00
c7aa3b422d lang: ast: fix lambdas starting with var declaration not being parsed correctly
IVY_KW_VAR is not treated as an expression start token (as variable declarations are not
strictly expressions). so the lambda parser did not create a block parser context
when it encountered this keyword.
2025-04-23 10:57:17 +01:00
279b387b69 lang: ast: complex-msg args are now separated by commas
additionally, unnamed complex-msg args no longer need to be prefixed
with a colon. this allows complex-msgs to more closely emulate
traditional function calls. this also applies to the call-operator.

for example, take the following lambda:

	var f = [ :x :y | ^x * 2 + y ].

before, this lambda would be invoked using the following syntax:

	f(:2 :4).

now, this syntax is used instead:

	f(2, 4).
2025-04-23 10:53:34 +01:00
f220fc2f4b lang: ast: fix nested lambdas not parsing correctly 2025-04-20 21:25:28 +01:00
25c1fbd44b lang: fix a bunch of memory leaks 2025-04-17 23:15:48 +01:00
a4504c0507 lang: ast: fix source formatting 2025-04-17 21:43:51 +01:00
51e07522e8 lang: ast: fix parens not allowing sub-keyword messages
previously, an expression like:

	x arg1:a arg2:(c subArg:d).

were being parsed incorrectly. This expression was parsed
as single -arg1:arg2:subArg: message being sent to x. the
parentheses around the `c subArg:d` sub-expression were
being ignored.

now, this expression is correcly parsed as the value
of `c subArg:d` being passed as a parameter to the message
-arg1:arg2:
2025-04-17 21:38:31 +01:00
f0e6237473 lang: codegen: redesign again to use purely pre-order ast traversal 2025-04-16 21:58:52 +01:00
e430b7b2f1 lang: add var keyword for variable declarations
the var keyword allows greater control over what scope a
particular variable exists in. it clarifies whether a new
variable is being defined or an existing variable is being
assigned to. it will also facilitate the implementation of
global variables.
2025-04-15 11:02:47 +01:00
80e001cdc1 lang: add user args to ast iterator; combine pre/post-order traversal modes
the caller can now provide a pointer arg to ivy_ast_node_iterate, which will
be forwarded to the specified callback function each time it is called.

the iterator now behaves similarly to fts, in that it visits each node
in both pre-order and post-order, and indicates to the callback whether
the current iteration is pre- or post-order.
2025-04-14 12:24:42 +01:00
fd91bb71c0 ast: implement postorder ast traversal 2025-04-14 09:46:27 +01:00
2235f9c0a9 lang: change symbols for properties and atoms to -> and $ respectively 2025-04-10 13:04:12 +01:00
df8d9689d1 lang: add null pointer check to arith_parse_left_paren
this fixes a crash that occurred when the call-operator was used on a lone ident in an expression.
2025-04-03 10:48:56 +01:00
78b2eb23c3 lang: ast: implement () operator parsing
the () operator can be used to call lambdas in a more functional way than the standard
message-send syntax

for example, with a lambda stored in variable `x`:

	x(a:2 b:6).

is equivalent to

	x call(a:2 b:6).
2025-03-26 21:10:12 +00:00
46d244a28d lang: ast: implement parsing of try-catch-finally statements 2025-01-16 13:17:08 +00:00
143d61e329 lang: ast: add support for multiple block termination tokens 2025-01-16 13:15:18 +00:00
f5eaac1a4c lang: fix underscopre not being treated as an expression start token 2025-01-15 21:11:19 +00:00
8b8a97c9a6 lang: ast: implement parsing of subscript operator 2024-12-08 17:08:29 +00:00
753afd7d87 lang: ast: implement parsing of tuples 2024-12-08 12:28:47 +00:00
1c3bb98714 lang: ast: rename IVY_AST_STATIC_PKG_ITEM to IVY_AST_PKG_ITEM 2024-12-07 21:46:24 +00:00
e8c30b65b5 lang: ast: implement support for multiple expression terminator tokens 2024-12-07 21:28:25 +00:00
209c47da68 lang: ast: implement parsing of static and dynamic package initialisers 2024-12-07 20:56:57 +00:00
d404e21b33 lang: ast: implement parsing of unnamed parameters 2024-12-07 10:07:20 +00:00
504fea6d9e lang: ast: fix expr type not being set when parsing a lambda 2024-12-06 22:46:24 +00:00
dba4f123d6 lang: ast: implement parsing of lambdas 2024-12-06 22:26:06 +00:00
68ad0655aa lang: ast: fix selector to_string not including keyword message labels 2024-12-06 22:25:33 +00:00
dc55cfa1f8 lang: ast: propagate block terminator token to child expressions 2024-12-06 22:24:48 +00:00
54c6fd7040 lang: ast: adjust and clarify the precedence of token parser callbacks 2024-12-06 22:24:08 +00:00
4c36615bc1 lang: ast: implement s_terminator in block parser for all symbols 2024-12-06 21:34:26 +00:00
67bfdef18a lang: ast: misc formatting and reference fixes 2024-12-06 21:33:53 +00:00
bd5e524241 lang: ast: replace ast node print callback with to_string 2024-12-06 20:24:08 +00:00
ae15f228d3 lang: ast: fix finalise_property not being called when parsing a right paren 2024-12-06 20:23:46 +00:00
41ef94bf3d lang: ast: fix incorrect property parser state struct name 2024-12-06 20:23:23 +00:00
1f7319458e lang: ast: implement parsing of properties 2024-12-06 19:47:27 +00:00
94c10dfbb2 lang: ast: implement parsing of f-strings 2024-12-06 13:46:58 +00:00
2bd3e96427 lang: ast: implement parsing of atoms 2024-12-06 13:46:41 +00:00
7ba0a05332 lang: ast: fix error when parsing message handler keyword-message selector 2024-12-06 13:23:02 +00:00
d3813dc514 lang: ast: treat bang (!) as an unconsumed expression terminator 2024-12-06 13:22:33 +00:00
d88d58be70 lang: ast: implement for-loop parsing 2024-12-06 10:02:31 +00:00
f3cd89c72a lang: ast: implement caret (return) parsing 2024-12-06 10:01:56 +00:00
d1855afc05 lang: add missing includes; misc formatting cleanup 2024-12-06 09:59:57 +00:00
5fe3231c9e lang: ast: fix match node type specifying wrong node size 2024-12-05 22:00:23 +00:00
9a4b074381 lang: ast: suppress debug output by default 2024-12-05 19:37:58 +00:00
1a4d6089a1 lang: ast: implement parsing of while-loops 2024-12-05 19:29:21 +00:00