Commit Graph

561 Commits

Author SHA1 Message Date
2158bb97fc Clean up struct code a bit 2024-09-18 01:01:15 -04:00
0829e1a2d1 Clean up enum code 2024-09-18 00:58:41 -04:00
7e0b1a3214 Deprecate linker directives 2024-09-18 00:43:13 -04:00
ec88848f6b Support explicit discards better by allowing multiple declared "_" vars 2024-09-18 00:30:05 -04:00
03a7d5f44d Overhaul of header logic so it now uses topological ordering and
deduplication for libraries with multiple files.
2024-09-17 16:20:30 -04:00
aaa51fc734 Perform topological ordering when compiling typedefs so users don't need
to think about ordering their definitions.
2024-09-17 15:17:13 -04:00
e5f432d4c9 Fix not x for optional values 2024-09-16 16:10:05 -04:00
de49bc5bb3 Deprecate :or_else()/:or_fail()/:or_exit() in favor of the or operator 2024-09-16 16:06:19 -04:00
821bde156c Support (optional or skip) 2024-09-16 15:48:06 -04:00
68c4731ae6 Show more error info 2024-09-16 14:27:18 -04:00
6b5a9d65e3 Overhaul of how libraries are installed 2024-09-15 21:18:42 -04:00
8a1ace4d65 Fix optional text CLI args 2024-09-15 17:53:20 -04:00
8ee23054bf Update Inline C syntax and documentation/tests 2024-09-15 17:34:34 -04:00
835eb7e896 Add optional:or_exit(...) 2024-09-15 16:42:42 -04:00
fb37b0ee42 Fix up if var := ...: in ternary expressions and optional checking
logic
2024-09-15 16:29:45 -04:00
e422079fcc Add a Byte datatype 2024-09-15 15:33:47 -04:00
c455e7b67d Rename builtins/ -> stdlib/ 2024-09-13 20:18:08 -04:00
34c562e88e Move cord helper functions into their own file 2024-09-13 14:23:24 -04:00
da9cc93c46 Make functions print with func name(...)->... [file:line] info 2024-09-12 23:41:32 -04:00
46a2aa2ffc Fix up comprehensions so set comprehensions work and everything is a bit
more clean
2024-09-12 14:27:13 -04:00
990846debb Add enum scoping to arrya/set/table literals 2024-09-12 13:11:03 -04:00
56a4d13975 Automatic promotion to single-argument enum tags with a unique type 2024-09-12 13:05:08 -04:00
1d05704fdd Use CString literals as constant values 2024-09-12 02:18:05 -04:00
327d466b95 Table:get() now uses optional values instead of default or failure modes 2024-09-12 00:55:43 -04:00
fa7e52787f Add postfix ! operator for optionals 2024-09-12 00:13:53 -04:00
8e300312a0 Change check_optional -> check_null 2024-09-11 23:55:49 -04:00
c034175ae1 Add optional:or_else(fallback) and optional:or_fail(message) 2024-09-11 23:17:03 -04:00
cfef667a89 Fix optional integer promotion 2024-09-11 23:13:41 -04:00
0f7cf28af1 Fix threads and integers 2024-09-11 22:50:03 -04:00
3443edf760 Use optionals for iterators 2024-09-11 22:28:43 -04:00
6723ea46c2 Bugfix big int literals 2024-09-11 15:03:39 -04:00
db0d5a1c20 Change *:from_text() methods to return optional values and set up CLI
parsing to use that approach
2024-09-11 14:53:48 -04:00
0b5bb32912 Fix optional bools 2024-09-11 14:18:01 -04:00
273e2f995f Rename channel_t -> Channel_t for consistency 2024-09-11 13:57:21 -04:00
75fbaa79bc Rename closure_t -> Closure_t for consistency 2024-09-11 13:56:39 -04:00
b0b23acf88 Rename "Nil"->"Null" for consistency 2024-09-11 13:55:41 -04:00
02930b84f8 Optionals for threads 2024-09-11 12:56:16 -04:00
908673c9d9 Optional channels (plus fixed some channel bugs) 2024-09-11 12:50:46 -04:00
30d39378c7 Optional C Strings 2024-09-11 12:39:56 -04:00
210179ee67 Optional enums (deprecated custom tag values) 2024-09-11 12:29:48 -04:00
dee3742b48 Optional structs 2024-09-11 12:01:17 -04:00
bba9f1b141 Optional fixed-size ints 2024-09-11 11:08:15 -04:00
0ca48c98e8 Support conditionals for tables/arrays/sets 2024-09-11 01:51:16 -04:00
989dc3f442 Support if x := blah: ... 2024-09-11 01:48:15 -04:00
7126755275 Add optional types 2024-09-11 01:31:31 -04:00
23de8e1f5a Fix up some stuff with path escaping 2024-09-09 16:54:08 -04:00
8e27f0e796 remove debug code 2024-09-09 16:09:13 -04:00
013fbe22e0 Clean up CLI path arrays 2024-09-09 14:55:04 -04:00
6ea6aadd96 Correctly clean up CLI args that are paths 2024-09-09 14:48:33 -04:00
a306f94557 Add mktemp functionality 2024-09-09 02:43:15 -04:00
13a9304dec Initial working version 2024-09-09 00:22:12 -04:00
711afee405 Fix non-base10 integer literals 2024-09-08 22:12:13 -04:00
a4fff5cb49 Bugfix for default arguments not supporting enclosing types 2024-09-08 21:55:15 -04:00
aeed1992e9 Fix nearly every GCC warning and add __attribute__((pure/const)) where
appropriate
2024-09-08 17:17:15 -04:00
3f16e95127 USAGE and HELP need an underscore prefix so they're not imported into
other files. Also fixed up dependency tool so it works good now
2024-09-07 00:26:30 -04:00
6cc5562791 Support using text in conditionals 2024-09-06 23:01:31 -04:00
11fa4f548c Support 'when' statements as expressions 2024-09-06 14:15:55 -04:00
4b352f89a3 Add Shell dsl type 2024-09-06 11:37:33 -04:00
c075deeab4 Actual fix for incref issue 2024-09-06 04:14:50 -04:00
dc7ee868a6 Speculative fix for some incref issues 2024-09-06 04:11:00 -04:00
e47c45a93b Bugfix for "":join(table.keys) 2024-09-06 03:46:35 -04:00
3444d1652d Add comment 2024-09-05 15:44:49 -04:00
d99f0271ad Revert "Use stack() macro" (actually needs to work this way)
This reverts commit ed36765b42.
2024-09-05 15:43:52 -04:00
ed36765b42 Use stack() macro 2024-09-05 15:35:40 -04:00
04c8fb0362 Replace $Type with Type$info for builtin TypeInfos 2024-09-05 15:31:54 -04:00
391c1b6bde Rename table_t -> Table_t 2024-09-05 14:57:31 -04:00
abe45a3c25 Rename array_t -> Array_t 2024-09-05 14:56:37 -04:00
c82b664db9 Slightly clean up CLI usage error code for no-argument programs 2024-09-05 14:44:52 -04:00
a8be9efcd3 Rework CLI compilation so that all of the argument parsing is written to
the .tm.c file and the runner program is *just* a single function call
to the function that parses args and runs the main function. Also
improved some CLI usage error code
2024-09-05 14:38:37 -04:00
e6aea8c130 Add support for custom HELP for CLI tools 2024-09-05 13:57:48 -04:00
e1d0927744 Fix 'empty' clause for integer iteration 2024-09-05 12:44:01 -04:00
34d98f067e For big or arbitrarily big integers not known to be constant, do full
Int$plus(a,b) logic so it's definitely correct and doesn't error.
2024-09-05 12:41:13 -04:00
e91b53f070 Improve codegen for loops by not adding extra braces and just using the
integer literal for 64-bit ints when iterating over a numeric value
2024-09-05 12:28:28 -04:00
d801681026 Add early outs for (or) and (and) reducers 2024-09-05 11:51:07 -04:00
0d3c8e16bc Add iteration-over-comprehension optimization 2024-09-05 11:23:00 -04:00
e2118b7407 Better enum messaging for CLI arg parsing 2024-09-04 21:33:06 -04:00
453c3610f9 Support parsing enums (without members) 2024-09-04 16:21:27 -04:00
3513b94fc7 Unify parsing code to correctly handle parsing integers and numbers with
a &success boolean. Check for overflow as well.
2024-09-04 16:08:34 -04:00
973b1c55c2 Fix array CLI arguments 2024-09-04 15:30:38 -04:00
e9796e1433 Improve command line parsing (no more cords) 2024-09-04 15:23:23 -04:00
0d098c118b Add automatic --help to print usage 2024-09-04 14:34:24 -04:00
ac507da537 Remove unused code path for >> f := use ./foo.tm 2024-09-04 13:49:41 -04:00
d1b2e9f598 Disallow 'use' statements that aren't top level 2024-09-04 13:48:26 -04:00
f605df8230 Minor codegen cleanup 2024-09-04 13:37:00 -04:00
97a964aa86 Implicit filename for table getting 2024-09-04 05:05:31 -04:00
af15e89303 For arrays, use implicit filename from macro 2024-09-04 05:04:45 -04:00
1092185c84 Improve codegen by making test() even more concise 2024-09-04 05:01:21 -04:00
79c1e8f989 Don't put __SOURCE_FILE__ in header 2024-09-04 03:04:42 -04:00
ec688c11bb Clean up codegen so $Foo"..." comes out as foo$Foo("...") instead of
Text("...")
2024-09-04 00:18:03 -04:00
805082d299 Minor codegen cleanup Texts(...) 2024-09-03 23:35:42 -04:00
f60edfbe7f Improve codegen for doctests a little bit by using __SOURCE_FILE__ macro
and making assignments use (x = 4, &x) syntax instead of ({ x = 4; &x })
2024-09-03 23:32:02 -04:00
e15cb21cd5 Fix up CLI parsing 2024-09-03 21:09:11 -04:00
29a87ff325 Support literal Text("blah") for text that is constant ASCII strings 2024-09-03 14:48:54 -04:00
5feecff9d9 Deprecate Where and change channel API to use a boolean front value 2024-09-03 03:53:36 -04:00
5a78eb61c8 Bugfix for hex escapes adjacent to hex-like characters 2024-09-02 21:54:38 -04:00
620ebeab8d Fixing string methods 2024-09-02 20:22:13 -04:00
337aa911a9 Auto promote to C String from Text 2024-09-02 19:53:09 -04:00
6d7a359f8f Bugfix some text replacement things 2024-09-02 19:49:52 -04:00
80a09e6dba Fix up some integer and print statement stuff 2024-09-02 19:29:43 -04:00
b0a8404bd7 Fix enums/structs 2024-09-02 19:18:21 -04:00
00a3117803 Bugfix 2024-09-02 19:07:51 -04:00
94761d9a5a Fix some stuff 2024-09-02 19:05:06 -04:00
61e482f6f3 Initial WIP first past 2024-09-02 18:47:39 -04:00
a197875214 Bugfix for say() when length is >512, and added back the newline
optional parameter (default=yes)
2024-08-23 12:42:10 -04:00
dceb925573 Bugfix for parsing ints 2024-08-23 11:38:54 -04:00
ad51b208b4 Overhaul of import syntax. Now everything uses use: use foo, `use
./foo.tm`, `use <foo.h>`, `use libfoo.so`
2024-08-22 14:02:48 -04:00
2055439be4 Variables can no longer hold function pointers, only closure_t's. This
makes error reporting easier and prevents issues where some functions
could be assigned, but not others. Also change outputs so Void returns
don't show up when displaying types, now just: `func()`
2024-08-21 00:49:22 -04:00
3c4f477b84 Bugfix some copy-on-write cases for when pointers are automatically
derefenced for method calls
2024-08-20 16:20:41 -04:00
5b945d8fc6 Remove unused parameter and add some docs on arrays 2024-08-20 16:00:58 -04:00
934b843b1c Add .text_content as a field on DSLs instead of a method 2024-08-19 14:29:58 -04:00
ea6f9797be Support DSL constructor working on DSL itself 2024-08-19 13:23:59 -04:00
4e732a718d Restructure things so that DSL constructors do proper escaping 2024-08-19 13:23:02 -04:00
178dca6e88 Clean up codegen for strings that are just a single interpolated value 2024-08-19 13:14:36 -04:00
8c4210ba01 Support demoting int literals 2024-08-19 12:39:45 -04:00
752be14eed Fix some numeric precision issues with how nums are printed 2024-08-19 01:46:37 -04:00
14b4a674e8 Fix precision of compiled numbers 2024-08-19 01:32:27 -04:00
c422806d87 Make sure imported/used modules are initialized properly 2024-08-19 00:52:35 -04:00
8363d53bd2 Update channel API to take a Where parameter 2024-08-18 23:59:13 -04:00
9e07c6adc7 Add Channel:peek() 2024-08-18 23:31:36 -04:00
2e8c949fdc Rename push/pop to give/get, since it's not stack-ordered 2024-08-18 23:24:23 -04:00
7472837ee5 Add array:first(predicate:func(x:&T)->Bool)->@%T? 2024-08-18 22:28:04 -04:00
6f3b2c073a Add enum.tag as a way to do a boolean test for whether a value has a
particular tag or not
2024-08-18 20:58:36 -04:00
967b649da2 Deprecate # operator in favor of .length and fix up some issues 2024-08-18 20:39:57 -04:00
d804b09b02 Added a .length field to arrays/sets/tables, added a .max_size field to
channels, and updated the API
2024-08-18 20:28:39 -04:00
6ef0583868 Fix array indexing 2024-08-18 15:51:19 -04:00
a49870f810 Add primality testing and next_prime()/prev_prime() 2024-08-18 15:22:51 -04:00
da4d07c665 Fix up some bigint logic issues 2024-08-18 12:47:29 -04:00
752ab8212c Split BigIntType out of IntType and switch to using enums for the size
of ints/nums
2024-08-18 11:49:51 -04:00
8b94c2c7f1 Fix array ++= item 2024-08-18 02:58:44 -04:00
d0078ab024 Handle demotion of integers when we know what the expected type ought to
be and it's just a literal.
2024-08-17 23:43:30 -04:00
09c4ff2e43 Disallow accessing type members that start with underscores unless
you're inside the type definition.
2024-08-17 21:03:04 -04:00
20b7793963 Make small integer constants actually constant 2024-08-17 15:17:41 -04:00
2383d73645 Correct the logic to prevent promoting nums to ints automatically 2024-08-17 15:14:45 -04:00
de31398fe4 Add table:get_or_null(key) for tables with non-null pointer values,
which lets get() keep the non-null return type
2024-08-17 15:01:01 -04:00
cbe117a6d3 Allow for top-level or namespace-level variables that are initialized
with non-constant values by the use of an initializer function and
runtime checks for whether the variable is initialized.
2024-08-17 14:41:31 -04:00
a6be5c90ca For cached functions with no arguments, use a static var instead of a
cache table
2024-08-16 01:46:05 -04:00
7c18773011 Bugfix for closures 2024-08-15 13:59:01 -04:00
688f883e16 Add array:find() 2024-08-15 03:01:04 -04:00
66ae30ac29 Add method for array:remove_item(item) and rename
array:remove(index)->array:remove_at(index) to avoid confusion. Also
hook up array:has()
2024-08-15 02:39:35 -04:00
ed1667cb37 Add array:shuffled() and checks for array insertion 2024-08-15 02:17:53 -04:00
eccc4e4721 Add binary search method to arrays 2024-08-15 01:59:42 -04:00
9c2d7c437d Fix up type conversions with ints and nums 2024-08-14 14:57:01 -04:00
e0223a4c20 Support ^ exponentiation for integers 2024-08-13 16:32:00 -04:00
5a0502bdf5 Fix some edge cases 2024-08-13 14:13:02 -04:00
1ce826b9c3 Tweak to codegen for range iteration 2024-08-13 11:35:22 -04:00
81ed38616f Cleanup code gen for Num coercions 2024-08-13 04:24:36 -04:00
eb9e5260a6 Fix channels 2024-08-13 03:27:32 -04:00
9edace28e2 Fix ranges 2024-08-13 03:20:01 -04:00
7365602715 Fixing up more stuff 2024-08-13 03:08:27 -04:00
6f33b93014 Fix min/max 2024-08-13 03:05:56 -04:00