Commit Graph

368 Commits

Author SHA1 Message Date
c12371f0ec lang: ast: add diag support to parser 2025-05-08 22:30:23 +01:00
a0f1931c00 lang: lex: update ivy_token to use ivy_char_cell 2025-05-08 22:27:13 +01:00
92f101e500 diag: adjust pretty print formatting 2025-05-08 22:24:50 +01:00
592acc693f common: add a row/column co-ordinate structure 2025-05-08 22:24:12 +01:00
ce8a12d4f7 frontend: update api usage with diagnostic support 2025-05-08 20:32:22 +01:00
a28874145c lang: lex: add diagnostic support 2025-05-08 20:31:55 +01:00
cc99e7440e lang: add diagnostic definitions 2025-05-08 20:31:40 +01:00
1977ae4fe8 diag: rename ivy_diag_set_line_source to ivy_diag_ctx_set_line_source 2025-05-08 20:30:21 +01:00
bb55bee7f8 common: implement s_get_row and s_get_name in ivy_file 2025-05-08 20:29:31 +01:00
9f963c5757 frontend: add token coordinates to print_lex_token output 2025-05-08 10:53:35 +01:00
475575f76f lang: codegen: add for-loop generator 2025-05-08 10:53:00 +01:00
c31638c3de doc: update simple example with for-loop 2025-05-08 10:52:18 +01:00
0cf7dd9780 test: add diagnostic test program 2025-05-08 10:49:32 +01:00
c459f50e67 meta: add ivy-diag library
ivy-diag is used for generating and emitting diagnostic messages during compilation.
2025-05-08 10:48:23 +01:00
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