Commit graph

69 commits

Author SHA1 Message Date
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
c748472187 Compress floats as much as possible. Also output NaN and Infinity as strings. 2014-07-28 20:38:44 +02:00
Sei Lisa
cd9fa96055 Format ELSE IF in a single line. 2014-07-28 19:36:01 +02:00
Sei Lisa
56d51b835c Hack to make identifiers in globals in non-global-expression mode work. 2014-07-28 19:20:36 +02:00
Sei Lisa
443b5a2258 Fix bug where floats in global lists would be output as integers. 2014-07-28 18:13:48 +02:00
Sei Lisa
d55f873fd5 Add tab warning and future option documentation. 2014-07-28 17:26:05 +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
8907a59d5f Fix remaining bug in optimizer, and minor fixes.
- Get rid of Fold().

- Handle globalmode properly. It was sometimes active during function calls.

- Change all warning() calls to not use Unicode, just in case the output is redirected to file.

- Cosmetic fixes and TODO items.
2014-07-27 23:33:20 +02:00
Sei Lisa
100de9c8e9 Fix output of lists < 5 elements 2014-07-27 21:23:57 +02:00
Sei Lisa
0f55129f71 Add important comment 2014-07-27 21:04:31 +02:00
Sei Lisa
f1656c41aa Import 'warning' from lslparse instead of redefining. Cosmetic fixes. 2014-07-27 18:05:11 +02:00
Sei Lisa
609df368f3 Fix a case with list mode for globals. 2014-07-27 13:47:18 +02:00
Sei Lisa
d856f62253 Fix optsigns treatment. 2014-07-27 04:31:45 +02:00
Sei Lisa
6e1357f4f3 Handle type cast optimization in the output module (easiest). 2014-07-27 04:24:14 +02:00
Sei Lisa
603b85afc8 Remove hack and output expressions where expected. 2014-07-27 02:18:37 +02:00
Sei Lisa
ecaa4b1af0 Output negative integers as hex. 2014-07-27 01:27:37 +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
841413a2cf Remove bogus FIXME comment. 2014-07-26 04:35:57 +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