Commit graph

736 commits

Author SHA1 Message Date
Sei Lisa
df8a8b4e9e Revamp command line options to add mcpp mode with defaults.
Also remove stderr from subprocess call (let the subprocess do its own output to stderr without capturing and re-emitting it ourselves).
2015-03-19 04:11:29 +01:00
Sei Lisa
226f382c4f Switch the predefined macros to variadic, to allow commas. 2015-03-17 19:41:36 +01:00
Sei Lisa
aea101a823 Add --precmd, bump version, report 'version N' instead of 'vN' on --version 2015-03-15 20:28:53 +01:00
Sei Lisa
f93e6d65a4 Deal with encoding issues, and simplify subprocess poll loop. 2015-03-15 20:01:41 +01:00
Sei Lisa
c8bec32242 Add a comment to prevent mistakes. 2015-03-15 19:49:52 +01:00
Sei Lisa
56f40a9c76 Ensure the script is Unicode before parsing. 2015-03-15 19:19:57 +01:00
Sei Lisa
31b7048fc9 Remove debug info left by mistake. 2015-03-15 19:19:10 +01:00
Sei Lisa
3c962ef32b Add external preprocessor invocation. 2015-03-15 06:18:55 +01:00
Sei Lisa
b8f73bb5e1 Don't open the script in binary mode, open it in text mode.
Not too sure about this change, but it eliminates CRs before LFs.
2015-03-15 02:18:01 +01:00
Sei Lisa
9e0ed0521b Reorganize main to use getopt. Implement -o for output file and -O help.
Also --version and -h/--help.
2015-03-14 23:17:15 +01:00
Sei Lisa
5b105e5772 Some enhancements to README.md 2015-03-14 11:33:43 +01:00
Sei Lisa
aa0d84e01b Another link fix *sigh* 2015-03-14 04:11:11 +01:00
Sei Lisa
a462b6b41d Fix link. 2015-03-14 04:10:11 +01:00
Sei Lisa
a947b63730 README.md: Move documentation to seis.shop.tm 2015-03-14 03:53:44 +01:00
Sei Lisa
9bd66dd6fa Optimize out function calls to SEF functions with non-SEF arguments.
The function call is removed, and the arguments transformed to a block of expression statements.
2015-03-13 23:48:24 +01:00
Sei Lisa
df31a69465 In functions that end in 'return;', remove the 'return;'.
This allows better side-effect analysis, because 'return' is not side-effect free unless it's the last statement. But that's better handled in the dead code removal module, as the comment specifies.
2015-03-13 23:46:23 +01:00
Sei Lisa
9cb02839bc Remove extra code. 2015-03-13 23:45:56 +01:00
Sei Lisa
f6b472133a Optimize [elem] -> (list)elem on output. Saves us headaches. 2015-03-13 22:42:00 +01:00
Sei Lisa
2948399bf8 Revert 3b7e461d82, as it introduced bugs. 2015-03-13 22:13:00 +01:00
Sei Lisa
f7556e7a66 Remove globals from symbol table when no longer necessary. 2015-03-13 20:11:57 +01:00
Sei Lisa
5ca8e3db3f Expand README.md with optimization explanations and an intro to the features. 2015-03-13 19:01:13 +01:00
Sei Lisa
2e2975ef95 Fix unit tests. 2015-03-13 16:56:32 +01:00
Sei Lisa
fc7abc7d99 Fix bug broken by 562154e7aa.
Referencing a global that was optimized out, caused a crash.

```
integer DEBUG = 1;

default
{
    state_entry()
    {
        if (DEBUG) llOwnerSay("DEBUG");
    }
}
```
2015-03-13 16:49:31 +01:00
Sei Lisa
3d965f13e0 Fix bug with the scope of function calls.
Makes this script work, as it should:

`default { timer() { string llSay; llSay(0, llSay); } }`
2015-03-13 16:43:35 +01:00
Sei Lisa
890e960b57 Implement Lazy List reading. Update docs according to last changes (in FS too).
Adds a new tree node type, SUBIDX, which hopefully should never appear in actual output. If it does, it's prefixed with the string (MISSING TYPE) as a cue to the programmer.
2015-03-13 06:38:35 +01:00
Sei Lisa
535dc8434c Allow a code block instead of a ':' as terminator for 'case' and 'default'.
For Firestorm compatibility.
2015-03-13 05:16:22 +01:00
Sei Lisa
39b6036671 Remove 'Scope' from functions in symbol table. Function scope is always 0. 2015-03-13 05:12:09 +01:00
Sei Lisa
4f8d2979aa Fix typo in EParseFunctionMismatch. 2015-03-13 03:28:51 +01:00
Sei Lisa
4065fa95bb FS's optimizer now sucks a bit less thanks to the author's contributions. 2015-03-11 06:10:41 +01:00
Sei Lisa
63e3021a6d Comment tweaking. 2015-03-09 13:20:37 +01:00
Sei Lisa
9c926b6fec Fix obsolete comment.
There was a time where I decided that the tree would be stored inside the symbol table, as values for the global symbols. I changed my mind later and separated them, but that comment remained.
2015-03-09 01:07:55 +01:00
Sei Lisa
6a0eebf157 Implement a couple subtleties of the lexer in the handling of strings.
First, a string does not have its own context, it's a regular expression, therefore if there isn't a matching closing quote until EOF, it's not an unterminated string. It plainly *isn't* a string.

Second, the string lexer searches for either the regexp '[^"\\]' (any character except a double quote or a backslash) or the regexp '\\.', that is, a backslash followed by an "any character" meta. But the "any character" meta does NOT match a newline. The consequence is that a '\' followed by a newline cancels the matching, and the whole thing is not considered a string.

Isolated double quotes are then plain ignored as many other characters.

An example illustrating both cases:
```
default
{
    state_entry()
    {
        string msg = "Hello, Avatar!";
        llOwnerSay"(msg); // the opening quote will be ignored
        // the following backslash at EOL cancels the previous double quote: \
        llOwnerSay(llGetKey(")); // Unterminated string; unmatched so ignored.
    }
}
```
2015-03-08 16:53:58 +01:00
Sei Lisa
defa9fde97 Typo in help 2015-03-07 22:55:25 +01:00
Sei Lisa
1e8b77bf50 Rather than generating random identifiers for locals, prefix them with 'loc_'.
Should help improving readability of the optimized script.
2015-03-07 14:51:51 +01:00
Sei Lisa
a292846d28 Fix missing scope table index when generating the call to lazy_list_set. 2015-03-07 14:50:25 +01:00
Sei Lisa
562154e7aa Remove the symbol table entry too when removing a global state/function/var. 2015-03-07 14:33:11 +01:00
Sei Lisa
b112494311 Support for other IDEs 2015-03-07 13:52:44 +01:00
Sei Lisa
2b56d06e60 Comment on lack of location info of warnings. 2015-03-07 13:41:20 +01:00
Sei Lisa
59cdd64228 Warn about float constants that can't be represented in globals. Also don't duplicate the globals warnings. 2015-03-06 23:26:58 +01:00
Sei Lisa
c1d837674c Forgot to exclude globals from this optimization somehow. 2015-03-06 22:55:28 +01:00
Sei Lisa
7c35cf64df Mention OS X command to pipe to clipboard. 2015-03-06 20:35:05 +01:00
Sei Lisa
a9179f2779 Read the data files from the same path where the script resides. 2015-03-06 20:29:54 +01:00
Sei Lisa
ac9f0c30a5 More tweaks to README.md 2015-03-06 20:26:44 +01:00
Sei Lisa
109d2b4324 README.md tweaks++ 2015-03-06 19:03:03 +01:00
Sei Lisa
e9d8af6e11 llGetKey example replaced with llGetOwner. 2015-03-06 03:44:21 +01:00
Sei Lisa
9e9997bc98 More README.md tweaks 2015-03-06 03:42:11 +01:00
Sei Lisa
7cedd7e157 Improvements to README.md 2015-03-06 03:22:06 +01:00
Sei Lisa
a304cf989c Add README.md 2015-03-06 02:58:29 +01:00
Sei Lisa
50c2787ef4 Reorder the help lines to make better sense. 2015-03-06 02:56:58 +01:00
Sei Lisa
ed17d3330d Updated builtins.txt and builtins.txt.dat 2015-03-05 23:37:43 +01:00