Commit graph

38 commits

Author SHA1 Message Date
Sei Lisa
7d0ee20058 Option -p needs an argument. 2015-05-05 22:50:28 +02:00
Sei Lisa
1c16355187 Small wording change. 2015-04-15 22:52:49 +02:00
Sei Lisa
921955f321 Implement function overriding syntax extension, fixing a bug on the way.
The funcoverride option allows defining multiple functions with the same name, each overriding the former. That's for compatibility with Firestorm, whose optimizer does that.

While on it, fix a bug where defining a function whose name matches a library function was not reporting an error, and rename self.functions to self.funclibrary for clarity. It also brings consistency with other parts of the code and with the code documentation.
2015-03-27 00:35:37 +01:00
Sei Lisa
29d003b108 Add a comment about C backslash-return behaviour. 2015-03-24 21:56:35 +01:00
Sei Lisa
47eee0312b Revamp and fixes of REs for pre-preprocessing.
Easier to follow and to maintain this way. Fixes known and potential bugs, plus potential lack of greediness.
2015-03-20 17:45:38 +01:00
Sei Lisa
cd1826e9e0 Bump version. 2015-03-19 04:31:47 +01:00
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
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
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
defa9fde97 Typo in help 2015-03-07 22:55:25 +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
50c2787ef4 Reorder the help lines to make better sense. 2015-03-06 02:56:58 +01:00
Sei Lisa
c68a1f4ad6 Add copyright notices to all files, to prepare the program for release. 2015-03-05 23:18:41 +01:00
Sei Lisa
d164b0fa44 Tweak the main help text. 2015-03-05 20:45:38 +01:00
Sei Lisa
cbcf60767a Implement break/continue and switch().
While on it, reorganize the help text and enable 'dcr' by default.
2015-03-05 01:37:32 +01:00
Sei Lisa
a6127cf144 lazylistcompat idea ditched. 2015-03-04 00:40:07 +01:00
Sei Lisa
30c492d2b3 Oops, fix a format string fail (the help wasn't shown). 2015-03-03 19:58:40 +01:00
Sei Lisa
b73805e0ce Add "lazy lists" assignment support (mylist[index] = value).
Add support for LAMBDA (empty) tree nodes while on it, that allow us to define private stuff at the top without caring about Loc.
2015-03-03 17:59:51 +01:00
Sei Lisa
8f83e2f1ab Add "addstrings" option (disabled by default) to select whether to automatically concatenate strings during constant folding. 2015-02-28 20:01:51 +01:00
Sei Lisa
db862bb4a6 Multi-commit:
- Fix a bunch of bugs found during the debut of the LSL calculator.
- Add infrastructure for functions to be able to produce a result or not depending on arguments. Fixes the llBase64ToInteger/llXorBase64/llXorBase64StringsCorrect cases where they are not deterministic, and allows for the addition of some extra functions whose value can be determined in some cases (e.g. llDetectedType(-1) is always 0). Added several such functions in a new module.
- Add the constant folding option to the help and the default options.
2015-02-11 05:43:13 +01:00
Sei Lisa
6c248c46e3 Implement the shrinknames option.
Fixes some bugs with the treatment of the shrink attribute, some others with the output of renamed stuff.
2014-08-01 05:07:50 +02:00
Sei Lisa
e29f16d3eb Add duplabels option (not yet implemented).
When disabled, it now disallows duplicate labels. The plan is that when enabled, it will auto-rename labels so that there are no repetitions within a function.

Add coverage tests too, and also a coverage test that was missed after the latest changes.
2014-08-01 00:33:20 +02:00
Sei Lisa
0a567b0a39 Clean up the help a bit, removing unimplemented options. 2014-07-31 02:02:53 +02:00
Sei Lisa
3ac4bc4f0d New option to optimize float-to-int conversion separately from sign optim.
The option is optfloats. Add support everywhere.
2014-07-31 01:37:18 +02:00
Sei Lisa
fb68273eed Turned everything upside down, and fixed a couple bugs.
Bugs fixed:
- %= and the new assignment operators were not emitting error on invalid types.
- List globals referenced in another global were duplicated entirely.
- Properly recognize -option in the command line.

Rest:
- Complete overhaul of the internal data structure.
  - Got rid of the symbol table plus mini-trees, and made everything one big tree plus an auxiliary symbol table.
  - No more special case hacks like using tuples instead of lists...
  - Got rid of the EXPR hack.
  - Dict-based, rather than list-based. Allows adding arbitrary data to any node or symbol entry.
- Added a few coverage tests for the new code.
- Return values can now be chained; the functions parameter requirement is gone. Still not fully convinced, though. My guess is that a parser object should be passed between functions instead. Will do for now.
2014-07-30 04:54:16 +02:00
Sei Lisa
02c84ca99c Add default options and option activation/deactivation. 2014-07-28 18:19:50 +02:00
Sei Lisa
a6b3a0946f Enable foldtabs warning 2014-07-28 17:39:35 +02:00
Sei Lisa
538d9ab66e Change -o to -O; document "-" as stdin 2014-07-28 17:28:12 +02:00
Sei Lisa
d55f873fd5 Add tab warning and future option documentation. 2014-07-28 17:26:05 +02:00
Sei Lisa
108bbe5395 Some documentation rewordings. 2014-07-28 02:44:51 +02:00
Sei Lisa
eab0bec84b Add preprocessor skip option, command line options and help, options for all functions, and enhance parentheses removal. 2014-07-28 02:13:08 +02:00
Sei Lisa
7f6351c5e6 Fix prob with output to pipe. Change output logic.
Now a return status of 0 doesn't invoke sys.exit.
2014-07-27 23:31:48 +02:00
Sei Lisa
a3354fae0e First steps in optimizer.
Still WIP, though, but it already optimizes e.g. this:

default { timer() { 2+2; } }

to this:

default { timer() { 4; } }
2014-07-26 21:32:01 +02:00
Sei Lisa
05d00e075b Initial commit. Status so far:
- Parser and output modules are thoroughly tested and working.
- Most LSL immutable functions are working; some not tested; llJsonSetValue not implemented.
- Parser recognizes the following flags that alter syntax:
   extendedglobalexpr: Allow full expression syntax in globals.
   extendedtypecast: Allow full unary expressions in typecasts e.g. (float)~i.
   extendedassignment: Enable the C assignment operators &=, ^=, |=, <<=, >>=.
   explicitcast: Add explicit casts wherever they are done implicitly, e.g. float f=3; -> float f=(float)3;.
  Of them, only extendedglobalexpr is useless so far, as it requires the optimizer to be working.
2014-07-26 02:43:44 +02:00