Commit Graph

454 Commits

Author SHA1 Message Date
8e8637882d common: add some new callbacks to ivy_line_source
these callbacks will be used to implement diagnostic messages.
2025-05-08 10:47:07 +01:00
1c3aff9ad3 lang: add start/end coordinates to lexer tokens 2025-04-28 22:53:21 +01:00
2cbbc4c349 doc: add a document describing potential non-obvious syntax errors
the errors documented here include cases where the error is detected
far away from where the actual malformed syntax is in the source file,
so any error message reported by the compiler needs to include enough
information to help the user find and resolve the error.
2025-04-28 17:00:51 +01:00
a94956ec78 mie.vim: add comparison and branch instruction highlighting 2025-04-28 15:51:53 +01:00
75b90cfcb9 test: update mie api usage to use new context parameter 2025-04-28 15:51:20 +01:00
de7d5c44cd lang: codegen: add missing ctx parameter to ivy_codegen_create prototype 2025-04-28 15:50:54 +01:00
ff136adbe7 frontend: compile: print ast nodes as they are passed to the code generator
when both -a and -i switches are specified, ast nodes will be printed as they
are passed to the code generator, rather than all at once /before/ code
generation.

this makes it easier to determine which ast node is causing a code generation
error.
2025-04-28 15:47:32 +01:00
7ba88b65f8 frontend: update mie api usage to use new context parameter 2025-04-28 15:47:24 +01:00
64d1015a3c lang: codegen: implement cond-group code generation 2025-04-28 15:44:44 +01:00
6af9b62b88 mie: implement comparison and branch instruction generation 2025-04-28 15:41:31 +01:00
1431cb7b47 mie: ctx is now used to query the type of a value
this allows value get_type callbacks to use mie_ctx to obtain mie_type pointers,
rather than having to define their own static versions of the type structs.
2025-04-28 15:40:32 +01:00
cbec21b90f lang: implement elif keyword for more complex if-statements 2025-04-24 09:45:26 +01:00
d37c07e5e4 lang: codegen: implement return generation 2025-04-24 09:25:36 +01:00
da4aa7df78 lang: codegen: function load now uses func type instead of id 2025-04-24 09:25:21 +01:00
9b460a584d mie: convert: text-write write_operand_func now treats func references as pointers 2025-04-24 09:24:15 +01:00
4295b0568b mie: convert: implement record text conversion 2025-04-23 15:44:17 +01:00
614329091c lang: codegen: implement unit-package and unit-import generation 2025-04-23 15:44:01 +01:00
ef4b4d2f66 mie: implemented array value type; restructure const value structures
there are now separate structs for all const types (int, string, etc),
rather than a single mie_const union.
2025-04-23 15:42:58 +01:00
4ea9683880 lang: codegen: lambda s_outer_block is now only initialised once 2025-04-23 11:02:47 +01:00
2062ee631c lang: codegen: fix pop_generator_recurse only popping generators with a value_received callback defined 2025-04-23 11:01:12 +01:00
2eb358457c lang: codegen: fix serialisation of selectors with unnamed args 2025-04-23 11:00:57 +01:00
857d99ea34 lang: codegen: codegen_load_variable now supports loading non-ptr variables 2025-04-23 11:00:16 +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
0cdefbeec3 doc: update complex-msg syntax examples 2025-04-23 10:55:54 +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
2673f29447 mie: add comma separtor between func arg text output 2025-04-22 21:32:12 +01:00
07d16e7454 lang: codegen: fix segfault when serialising selector with unnamed args 2025-04-22 21:31:44 +01:00
833c80534e doc: update mie msg instruction syntax samples 2025-04-22 15:33:53 +01:00
83b05259f8 meta: update clang-format config
some source files are recognised as objc source files due to the use
of array initialiser macros. because of this, the C/C++ formatting settings
defined in .clang-format weren't being used.

now, the correct settings are applied for objc files too.
2025-04-22 15:32:08 +01:00
1942070c4e frontend: repl: disable post-order ast printing 2025-04-22 15:31:51 +01:00
b8459f9390 lang: codegen: implement lambda variable capture 2025-04-22 15:31:23 +01:00
7483b32c25 lang: codegen: redesign variable definition/resolution system to support capturing
the codegen scope system has been removed. instead, each generator state in the stack,
from the current state backwards, is informed when a variable is defined, resolved, or
captured.

when a variable is defined, the state stack is traversed back-to-front (current generator
first). each state has a chance to record the variable definition. once one state has
signalled that it has recorded the variable definition, the traversal ends.

when a variable is resolved, the state stack is traversed back-to-front (current generator
first). each state is asked whether or not it recognises the variable identifier being resolved.
if a state has the variable in question defined, it returns information about the variable
definition, and the traversal stops.

once a variable has been resolved, the state stack is traversed front-to-back (current generator
last), starting from the generator /after/ the one that provided the variable definition. each
generator in the iteration is given the chance to adjust the variable information, or generate
IR in response to the variable being accessed. this is used to implement variable capture,
where the state of a variable in the enclosing context is captured for later use.
2025-04-22 15:23:42 +01:00
dc000ae8ef common: implement conversion from b_status to ivy_status 2025-04-22 15:22:49 +01:00
79a818dd8e test: update mie tests 2025-04-22 15:22:28 +01:00
4ffe445572 mie: add strict-naming support to mie_name_map
in strict mode, the hint is taken as the required name. if a value already
exists with the given name, the operation fails.
2025-04-22 15:21:30 +01:00
f8c322ef6c mie: convert: add support for converting more value types 2025-04-22 15:20:43 +01:00
f0869b5ba0 lang: codegen: start implementing lambda generation 2025-04-21 21:11:45 +01:00
8023ea622a mie: func name and args are now specified separately from func creation
func args are added manually using mie_func_add_arg, while the func's name
is specified when the func is added to a module, to allow the module to generate
a unique name.
2025-04-21 21:10:27 +01:00
8febd270ba mie: convert: add spacing between function definitions 2025-04-21 21:10:14 +01:00
f220fc2f4b lang: ast: fix nested lambdas not parsing correctly 2025-04-20 21:25:28 +01:00
4a258e2580 lang: codegen: implement fstring generation 2025-04-18 23:17:39 +01:00
2ddb065243 lang: codegen: disable CODEGEN_F_IGNORE_RESULT in expression generation
this flag caused some issues where the result of a message would
be ignored if it was the first operand in a larger expression.
2025-04-18 23:15:28 +01:00
78817b6b8c update: use updated parser api to fix memory leaks 2025-04-17 23:16:16 +01:00
25c1fbd44b lang: fix a bunch of memory leaks 2025-04-17 23:15:48 +01:00
11449b9919 lang: codegen: add support for non-fstrings to expr generator 2025-04-17 22:55:40 +01:00
9cce4bf541 mie: implement caching and emitting string data 2025-04-17 22:55:17 +01:00
abb7cfaf0e mie: move mie_ctx to a separate header 2025-04-17 22:25:36 +01:00
7b8d77a264 lang: codegen: implement message-send code generation and global var references 2025-04-17 21:44:38 +01:00
a4504c0507 lang: ast: fix source formatting 2025-04-17 21:43:51 +01:00