Commit graph

142 commits

Author SHA1 Message Date
arookas
d070143fba Added local-keyword node 2016-02-01 01:40:30 -05:00
arookas
b57c70ee9d Added callable/storable modifiers to grammar
Still gotta add logic for them in the compiler.
2016-02-01 01:36:13 -05:00
arookas
5fa362cac1 Cache GetId result 2016-02-01 01:33:39 -05:00
arookas
837b2f8c8d Added null-check to GetId
Not the best fallback return value, but meh.
2016-02-01 01:32:09 -05:00
arookas
5483073347 Added local keyword 2016-02-01 01:28:00 -05:00
arookas
9d6eb5a75c Renamed GetReader to CreateReader
I feel this better documents what is actually happening (i.e. the reader
is not a cached value and is instead generated per call).
2016-02-01 00:26:50 -05:00
arookas
ebfa60f9ba Cleanup 2016-02-01 00:25:49 -05:00
arookas
f2d46235ee Fixed: importing didn't increment context locals 2016-02-01 00:24:16 -05:00
arookas
c0e747d2bd Added local-scope for functions & script variables
Also moved name-mangling logic to its own function. Next, adding actual
support in the language.
2016-02-01 00:22:31 -05:00
arookas
32b716a3b9 Minor cleanup 2016-01-31 23:17:10 -05:00
arookas
e575a8a741 Refactored parameter/argument list productions
Now the ellipsis is validated at parse time directly in the grammar,
instead of in the sunParameterList constructor (possibly giving better
error messages). I was also able to remove the parameter/argument
transcient productions.
2016-01-31 23:13:09 -05:00
arookas
e57a55056b Tabbing 2016-01-31 21:32:41 -05:00
arookas
be3c2b1582 Removed useless header information 2016-01-31 21:31:43 -05:00
arookas
b0ad55a005 Changed how call sites are opened/closed.
Now builtin symbols also have call sites. I had to move the call-site
property out of the base class because builtins need to store
argument-count information as well.
2016-01-31 21:26:51 -05:00
arookas
b2330dfa6c Refactored break/continue compilation.
I didn't like the null overload usage. I might remove the overload
completely later.
2016-01-31 21:25:50 -05:00
arookas
eb3e679fc7 Complete overhaul of binary-writing system
- Merged sunWriter and binary-writing code from sunContext into
sunBinary
- Changed compilation functions to take sunCompiler instance instead of
a sunContext
- Completely removed links between context and binary
- Moved import logic to sunCompiler
- Made sunContext and sunBinary properties on sunCompiler so compilation
functions can access them
2016-01-31 20:03:12 -05:00
arookas
8f683d16a3 Moved system symbols to their own function 2016-01-31 14:57:08 -05:00
arookas
16cba6c798 Added position functions to sunWriter 2016-01-31 14:29:15 -05:00
arookas
6292c2f9c5 Added $switch system variable. 2016-01-29 21:56:49 -05:00
arookas
c87bad17d7 Added consume flags for loops
Obviously in preparation for switch statements.
2016-01-29 21:56:25 -05:00
arookas
fcff623c29 Fixed: argument_list should not be transcient.
This caused errors in single-parameter function calls when expressions
had more than a single term.
2016-01-29 15:24:30 -05:00
arookas
e721b64045 Fixed: forgot to escape the n 2016-01-25 23:59:46 -05:00
arookas
df827b5acd Added AddSystemVariable. 2016-01-09 20:09:12 -05:00
arookas
6b47a372ed Renamed sunLoop to sunLoopNode. 2016-01-09 20:08:10 -05:00
arookas
31adcc5d6c Made system builtins properties instead of an enum. 2015-12-31 05:49:29 -05:00
arookas
4365a6b894 Fixed: close all call sites. 2015-12-31 05:43:45 -05:00
arookas
9f8f21c7bf Changed how system builtins are initialized. 2015-12-28 23:27:17 -05:00
arookas
ed4822ee29 Moved dump and print to common.sun. 2015-12-28 23:24:08 -05:00
arookas
72ea2a031c Renamed sunWriter writing methods to match the command names in TSpcInterp. 2015-12-28 20:35:16 -05:00
arookas
2ce9882cad Moved name labels to the statement production. 2015-12-28 20:19:12 -05:00
arookas
649e01b7c5 Fixed: removed [name_label] from if_statement.
IDK how that got there lol
2015-12-28 20:18:43 -05:00
arookas
75be2d41c1 Added a name-label stack.
Not like it really needs to be a stack, but just in case.
2015-12-28 20:16:12 -05:00
arookas
a7da66f9a9 Added a parameterless overload to Push. 2015-12-28 20:15:12 -05:00
arookas
814282fa0d Fixed: prevent recursive const definitions and assert for actual constancy. 2015-12-28 14:31:51 -05:00
arookas
54bd3618e3 Added expression analysis.
Also gave the AST cast nodes a base class while I was at it.
2015-12-28 14:22:54 -05:00
arookas
6be1779781 Added an error for constant expressions. 2015-12-28 14:20:44 -05:00
arookas
5f3c86669b Changed break/continue error messages. 2015-12-28 14:19:14 -05:00
arookas
7c9aa8fe89 Cleanup. 2015-12-28 14:17:09 -05:00
arookas
6997b75403 Renamed AnalyzeExpression. 2015-12-28 13:15:13 -05:00
arookas
41f69f76bb Fixed: incorrect define name for variable packing. 2015-12-28 10:36:31 -05:00
arookas
2f9b251fd8 Cleanup.
TIL I can set the automatic formatting of opening braces in VS. What
have I been doing all this time??
2015-12-28 03:37:10 -05:00
arookas
aa61439095 Renamed sunVariableAssignment. 2015-12-28 02:50:06 -05:00
arookas
af2255fbe5 Renamed sunConstDefinition. 2015-12-28 02:49:34 -05:00
arookas
d52ef38a89 Fixed: updated variable count in header. 2015-12-28 02:48:37 -05:00
arookas
1b514eecff Made variable-packing optional. 2015-12-28 02:47:49 -05:00
arookas
63740ea381 Fixed: hierarchy treated variable assignments as definitions in local counting. 2015-12-28 02:44:43 -05:00
arookas
72387d95eb Updated the assignment-operator compilation code. 2015-12-28 02:40:42 -05:00
arookas
de28ee84f9 Refactored declaration code. 2015-12-28 01:22:54 -05:00
arookas
fd21da0982 Fixed: don't count constants when calculating global/local counts. 2015-12-28 01:22:26 -05:00
arookas
d1d1a2a4a0 Added script- and function- roots. 2015-12-28 01:09:43 -05:00
arookas
372c622b84 Added storable and constant counts. 2015-12-28 00:59:26 -05:00
arookas
b387609a56 Cleanup. 2015-12-28 00:57:43 -05:00
arookas
3fd8c28230 Cleanup. 2015-12-28 00:50:52 -05:00
arookas
237c6f746f Refactored variable- and constant- resolution. 2015-12-27 23:41:37 -05:00
arookas
61e0b220b4 Removed WriteSymbolTable and WriteStringTable. 2015-12-27 23:10:11 -05:00
arookas
80c4c94b28 Cleanup. 2015-12-27 22:58:15 -05:00
arookas
0794267ff0 Added DeclareConstant. 2015-12-27 22:57:06 -05:00
arookas
c8056ac960 Cleanup. 2015-12-27 22:54:18 -05:00
arookas
4d947f5b6f Cleanup. 2015-12-27 22:51:42 -05:00
arookas
402459d997 Removed DeclareParameter. 2015-12-27 22:48:44 -05:00
arookas
e9ee07f15c Removed unusedd sunConstInfo class. 2015-12-27 22:48:17 -05:00
arookas
0840a33f9b Complete rewrite of the symbol resolution API.
- Constants are now symbols alongside variables in the "storable" symbol
class.
- Added Resolve* and MustResolve* versions in the new symbol-resolution
API.
- Moved storable-symbol compilation code out of the AST classes and into
the respective symbol classes. Storable symbols have extra compile
methods for get, set, increment, and decrement operations.
- Adapted the scope class accordingly.
- Added checks against assignment to constant symbols (which all throw
sunAssignConstantException).
2015-12-27 22:39:55 -05:00
arookas
664d1e227e Added constant-assignment exception. 2015-12-27 21:56:52 -05:00
arookas
eb636f2674 Added sanity check. 2015-12-27 21:05:38 -05:00
arookas
7e6c43d91e Token class cleanup. 2015-12-27 21:05:25 -05:00
arookas
af2a00f225 Added open/close sanity checks. 2015-12-27 21:04:29 -05:00
arookas
a5ec72e1f9 Member field naming convention. 2015-12-27 21:03:38 -05:00
arookas
063a092730 Fixed: don't redeclare the builtin. 2015-12-27 21:00:21 -05:00
arookas
8f9e8b75f5 Revert "Add script-scope variables to the symbol table."
This reverts commit ee5cff3900.
2015-12-23 20:38:47 -05:00
arookas
ee5cff3900 Add script-scope variables to the symbol table. 2015-12-23 20:30:07 -05:00
arookas
102f623cd1 Made ResolveVariableOrConstant less hacky. 2015-12-23 20:28:03 -05:00
arookas
c4532d85e7 Fixed: clear the tables and stacks from the previous operation. 2015-12-23 20:22:37 -05:00
arookas
c4fc1f9f4f Added a clear function. 2015-12-23 20:21:58 -05:00
arookas
0ab5431c5f Made variable symbols write a custom name. 2015-12-23 20:20:13 -05:00
arookas
684a8a3197 Made symbols write their table entries themselves.
This will allow for overriding the writing code for specific symbol
types.
2015-12-23 20:17:16 -05:00
arookas
ac51f19b85 Fixed: correctly calculate symbol-name lengths.
Even though the grammar promises us the symbol names will never occupy
more than one byte per character, it's good practice to add this anyway
(since we already do it for the data table).
2015-12-23 20:08:54 -05:00
arookas
7672bea631 Removed the unused sunFileArgs class. 2015-12-23 20:03:40 -05:00
arookas
cde799eadd Added an open/close interface to the context class. 2015-12-23 20:03:14 -05:00
arookas
44eab8e9e6 Fixed: don't recurse into function bodies when calculating maximum local counts. 2015-12-21 04:57:00 -05:00
arookas
694210cd5a Fixed: incorrect variable count in header. 2015-12-21 04:55:00 -05:00
arookas
8e4d9acb31 Made CalculateMaxLocalCount a property. 2015-12-21 04:50:17 -05:00
arookas
9ace3833cb Renamed symbol table classes. 2015-12-21 04:49:22 -05:00
arookas
d804f7dd66 Moved mkfr compilation to before the function body. 2015-12-18 19:52:23 -05:00
arookas
7c7ab8790e Added CalculateMaxLocalCount. 2015-12-18 19:51:23 -05:00
arookas
5a3a01ac8b Made compound statements their own AST node type. 2015-12-18 19:50:55 -05:00
arookas
73257ed389 Removed support for compound assignment definitions. 2015-12-18 18:57:24 -05:00
arookas
a7e10679d4 Added PushAddress (SPC command 0x3). 2015-12-14 14:47:19 -05:00
arookas
c7853af3cf Added nop (SPC command 0x5). 2015-12-14 14:47:04 -05:00
arookas
e7c2318a4b Made better error messages for sunImportException. 2015-12-13 01:20:26 -05:00
arookas
6edee006ad Renamed 'sunScriptException' to 'sunSourceException'. 2015-12-13 00:57:21 -05:00
arookas
96174aa074 Moved grammatica-.1.6.dll. 2015-12-12 17:38:44 -05:00
arookas
e5c8e9a8b7 Moved the ssc API code to its own folder. 2015-12-12 17:00:04 -05:00