Commit Graph

35 Commits

Author SHA1 Message Date
Aryadev Chavali
42ac4f6bbb lib/vec: vec_reset and vec_pop 2026-01-29 03:23:43 +00:00
Aryadev Chavali
7e3dd2679d parser/ast: Remove union name in ast_node_t
Destructures the names of the union into the namespace of the
structure itself; bit easier to use IMO.
2026-01-29 03:15:51 +00:00
Aryadev Chavali
8764b65aff parser: remove NIL as a known value
Not really needed or necessary.
2026-01-29 03:15:12 +00:00
Aryadev Chavali
2e24d3a618 parser/parser: slight tidy up in parse_string/parse_symbol 2026-01-29 03:14:36 +00:00
Aryadev Chavali
645ea5a04e main: Fix trivial pipes error in read_pipe, better comments overall. 2026-01-28 09:49:42 +00:00
Aryadev Chavali
9d8a0c1e22 examples: Remove newline from end of hello-world 2026-01-28 09:07:22 +00:00
Aryadev Chavali
65e4dc0b29 main: command line arguments for filename, and allow stdin parsing
- Now take a single command line argument for the filename to read and
  compile.
- If filename is "--", then read stdin until EOF using a different
  read handler (using ~vec_t~ along with buffered reading).
2026-01-28 09:06:00 +00:00
Aryadev Chavali
afc0f9c034 main: deal with file read errors more appropriately, unify error interface
- ~read_file~ now returns an error code and takes the ~sv_t~ (which
  contains the file contents) by pointer.  We can now deal with the
  error in ~main~ directly.
- Make the return code of ~main~ a variable which error branches can
  set.  Unify the error branch and normal branch code.  Pattern for
  error handling is now unified.
2026-01-28 09:02:46 +00:00
Aryadev Chavali
84996130b7 base: Added some extra logging macros
LOG, LOG_ERR.  LOG_ERR will always compile to a /stderr/ print.  LOG,
on the other hand, may not actually do anything if VERBOSE_LOGS is
not 1.  By default it is 0, so it must be defined when compiling to
enable - hence the adjustment of the Makefile.
2026-01-28 08:59:29 +00:00
Aryadev Chavali
0beab4e11d *: small changes 2026-01-28 07:35:45 +00:00
Aryadev Chavali
2dc0de78b5 parser/ast|parser: PRIMITIVE -> KNOWN
Primitive is a bit of a word conflict here; primitives are what we'd
expect our callables to be named eventually.  However, these parser
"primitives" are just well known symbols that we want to optimise the
representation of for later stages.  Thus, KNOWN is a bit better for
signalling intent then PRIMITIVE is.
2026-01-28 07:35:39 +00:00
Aryadev Chavali
947e05cdc8 parser/ast: update println -> putstr 2026-01-28 07:13:41 +00:00
Aryadev Chavali
e5152aac67 examples: Adjusted hello world example for new ideas in arl.org 2026-01-28 07:03:19 +00:00
Aryadev Chavali
42447e5bd8 arl.org: Lots of thinking 2026-01-28 07:03:12 +00:00
Aryadev Chavali
85f5502681 Makefile: Added recipe for generating compile_commands.json 2026-01-24 14:17:40 +00:00
Aryadev Chavali
fda4a63732 main: Fix comments referencing main.cpp 2026-01-24 03:06:37 +00:00
Aryadev Chavali
64fe3fc112 lib|parser: Fix references to headers 2026-01-24 03:06:19 +00:00
Aryadev Chavali
76872179f9 *: Split off headers into their own folder
Main reason is so we don't have that stupid arl prefix directory in
our source code.  Now our source code is flat, and we can still
reference headers by linking from root.
2026-01-24 03:02:54 +00:00
Aryadev Chavali
6d507e239c parser: Better AST primitives
commit 1588e7b46d
Author: Aryadev Chavali <aryadev@aryadevchavali.com>
Date:   Sat Jan 24 02:55:12 2026 +0000

    parser/parser: parse_symbol now supports primitives

    parse_symbol now investigates if the parsed symbol data is actually
    just a primitive (linear search through all primitives).  If it is,
    return a primitive first.  Otherwise, generate a symbol as per
    previous form of routine.

commit 62c91990c4
Author: Aryadev Chavali <aryadev@aryadevchavali.com>
Date:   Sat Jan 24 02:40:26 2026 +0000

    parser/ast: Added support for node level primitives

    These are just an enumeration of primitives we already expect to be
    present within a program.  Instead of leaving everything as a symbol,
    we can compile certain symbols into the enumeration ahead of time to
    make later stages easier.
2026-01-24 02:58:07 +00:00
Aryadev Chavali
51d59b6a83 spacing 2026-01-24 02:39:56 +00:00
Aryadev Chavali
92978cf71a parser/ast|parser: obj_t -> ast_node_t
Better naming so we don't conflict with stuff from code generation.
2026-01-24 02:39:56 +00:00
Aryadev Chavali
f09e720c7f parser/ast: Some renaming and namespacing of enumerations 2026-01-24 02:39:53 +00:00
Aryadev Chavali
10613f4a75 Makefile: factor out modules to make directory generation easier 2026-01-24 01:29:50 +00:00
Aryadev Chavali
639ceb3c93 README and arl.org 2026-01-24 00:35:38 +00:00
Aryadev Chavali
55640a36ae Makefile: dependency generation
My previous idea was to generate a list of all the headers, and add it
as a dependency for all object files.  This way, any changes in a
header would trigger a rebuild of all object files, which would
in-turn trigger a build of the binary.

This will be a bit of an issue later on when we have stuff that's
independent of others; a change in parser code won't necessarily
affect code generation, but a change in AST will.  We don't want to
re-trigger builds for everything.

This setup forces gcc to generate a clear set of dependencies in the
build folder (in a syntax recognisable by Make), then include that in
the Makefile itself.  These dependencies are specific to each code
unit and so only concern the headers that code unit uses.
2026-01-22 22:38:32 +00:00
Aryadev Chavali
9b7adbbbe1 *: documentation 2026-01-22 22:20:28 +00:00
Aryadev Chavali
2576f04309 main: Update to use the parse_stream_get_line_col function 2026-01-22 21:55:14 +00:00
Aryadev Chavali
c21b4f06d1 parser/ast|parser: Use byte as indicator of position instead of line/col
Much faster than dealing with the line and column as we go.  In the
vast majority of cases this data is completely unnecessary, so this is
wasted effort.  At the point where we need accurate line/column
information, we can compute it - in an error state, it really doesn't
matter that we're spending that extra time to compute it.
2026-01-22 21:53:42 +00:00
Aryadev Chavali
a96c24a553 main: Used pretty printers to present the parsed objects 2026-01-22 21:46:39 +00:00
Aryadev Chavali
737986eb54 parser/ast: Added pretty printers for objects and ASTs 2026-01-22 21:46:35 +00:00
Aryadev Chavali
3354625094 parser/parser.c: parser subroutines prototypes
Even easier to read now: the main routine (parse) is close to the top
of the code unit, and the rest fall underneath in order of importance.
2026-01-22 21:46:35 +00:00
Aryadev Chavali
7955cac4a1 parser/parser.c: stream function prototypes
I've made prototypes for them, put at the top, and moved their
implementations to the bottom.  They're not exposed to anything
outside this code unit.  Now, when reading the code, the parsing
routines (which are the main reason to be here) are at the top and
clear to read.
2026-01-22 21:45:20 +00:00
Aryadev Chavali
a977f01a2a A whole host of stuff
We now have a primitive and not fully tested parser for strings and
symbol sequences.  We record the lines and columns of each object on
the object for better compile time error handling.

I've also structured the code base in a slightly weirder fashion,
which makes my includes look nicer.  I've split up stuff quite a bit
to ensure code units are bit more focused.
2026-01-22 21:25:30 +00:00
Aryadev Chavali
4ec6dd8259 Switch to C instead of C++, added example, program now reads file 2026-01-22 18:08:34 +00:00
Aryadev Chavali
4ac780e3e9 hello world! 2026-01-22 18:06:42 +00:00