Commit graph

100 commits

Author SHA1 Message Date
Sei Lisa
06f8370886 Add a reference to the author name's origin
Add TODO on vectors and rotations, too.
2019-01-10 21:56:26 +01:00
Sei Lisa
41515f338a Disable inline by default, due to the impact it has on WHILE/FOR loops 2019-01-06 01:18:14 +01:00
Sei Lisa
a800604632 Add a request to change the usage text if the GPL version is changed 2019-01-06 00:52:54 +01:00
Sei Lisa
f243f3a3c1 New copyright year 2019-01-01 22:54:34 +01:00
Sei Lisa
a4986f21df Add 'inline' directive to forcibly inline function calls 2019-01-01 22:30:18 +01:00
Sei Lisa
fab3ce4d24 Add note on removal of comments in help text 2018-12-22 16:02:08 +01:00
Sei Lisa
1207275a1e Make --prenodef work more sensibly, remove caveat
--prenodef was causing the preprocessor-specific options (like -std=c99 for gcpp or -V199901L for mcpp) to be omitted. That makes no sense; '-p ext' should be used when custom options are desired (also modify the text that mentions it to make that clearer). Only the macros should be omitted.

The comment that warned about side effects with the order of --prenodef with respect to -p no longer applies, so remove it.
2018-10-15 21:18:15 +02:00
Sei Lisa
1d7142a698 Add --bom command-line option to prefix the script with a BOM 2018-05-11 22:37:09 +02:00
Sei Lisa
d0d6d6744b Bump copyright year
The help text in main.py was still at 2015. Oops.
2018-03-23 16:36:45 +01:00
Sei Lisa
b284f95f98 Bump version to 0.2.2beta 2018-01-18 16:02:38 +01:00
Sei Lisa
ed05a2e022 Make PreparePreproc Unicode-aware.
Fixes mismatches in column number output after a multiline string, if the last line of the string contains non-ASCII Unicode characters.
2017-11-26 14:10:33 +01:00
Sei Lisa
eba4df6903 Add preproc user args before internal args, rather than after them.
This allows using e.g. --precmd=python --prearg=mypreproc.py and still benefit from automatic defines, but on the negative side (or not?), it doesn't allow user options to override mcpp/gcpp internal options; user is forced to use -p ext in that case.
2017-11-26 14:02:04 +01:00
Sei Lisa
e2de571f98 Allow --prenodef to be used anywhere in the command line. 2017-11-26 14:00:46 +01:00
Sei Lisa
26c4770bab Remove mcpp_mode.
Use preproc=='mcpp' instead, which works the same and adds less noise.
2017-11-26 13:33:18 +01:00
Sei Lisa
f492d3e291 Add --prettify option, to reformat a script (losing comments).
Since our syntax extensions transform the source at parse time, all syntax extensions are disabled. The optimizations are disabled too, as it doesn't make sense to prettify and optimize at the same time (the optimizer would remove the constants that we're trying to keep).

Addresses #4 in a more user-friendly way.
2017-11-20 20:59:45 +01:00
Sei Lisa
70f39d7f5e Remove "magic names" where possible, using new data from fndata.txt 2017-10-27 23:39:26 +02:00
Sei Lisa
214d4a8a57 Add and read function properties table.
This solves a long-standing issue where we needed more data about LSL functions than just whether it's side-effect-free.

There's still some debug code, which is kept for history purposes.
2017-10-21 10:00:31 +02:00
Sei Lisa
3f6f8ed8ad Internal code reorganization.
- Separate library loading code into a new module. parser.__init__() no longer loads the library; it accepts (but does not depend on) a library as a parameter.
- Add an optional library argument to parse(). It's no longer mandatory to create a new parser for switching to a different builtins or seftable file.
- Move warning() and types from lslparse to lslcommon.
- Add .copy() to uses of base_keywords, to not rely on it being a frozen set.
- Adjust the test suite.
2017-10-20 18:19:48 +02:00
Sei Lisa
1071941301 Implement accurate error reporting through #line directives.
Also simplify and fix the matching expression for #line (gcc inserts numeric flags at the end).

It still has many problems. It's O(n^2). It's calculated at every EParse, and EParse can be triggered and ignored while scanning vectors or globals. UniConvScript doesn't read #line at all, thus failing to report a meaningful input line. But at least it's a start.
2017-10-11 05:04:13 +02:00
Sei Lisa
3214c553b2 Enable C99 mode for mcpp by default. 2017-10-09 00:05:35 +02:00
Sei Lisa
c544b51e37 Rewrite ReportError() and change EParse to report columns in chars.
ReportError() needed to account for terminal encodings that don't support the characters being printed. It was also reporting an inaccurate column number and its corresponding marker position, because the count was in bytes, not in characters, so that has been fixed.

Now EParse.__init__() calls a new function GetErrLineCol() that calculates the line and column corresponding to an error position.

The algorithm for finding the start of the line has also been changed in both ReportError() and EParse.__init__(); as a result, function fieldpos() has been removed.

The exception's lno and cno fields have been changed to be 1-based, rather than 0-based.

Thanks to @Jomik for the report. Fixes #5.
2017-10-05 18:50:45 +02:00
Sei Lisa
a6a08fe3f3 Implement transformation of lists into additions.
If the list in brackets is SEF:
  [a, b, ...]  ->  (list)a + b + ...
  ListExpr + [a, b, ...]  ->  ListExpr + a + b + ...
2017-09-15 22:30:22 +02:00
Sei Lisa
fe574bb462 Bump copyright year.
'bout time.
2017-08-09 19:45:46 +02:00
Sei Lisa
dd6a65bb03 When including source at the top, make it more intelligible.
Avoid breaking URLs in particular.
2017-08-09 17:48:23 +02:00
Sei Lisa
b4d9d5bc8c Note that ListLength depends on constant folding. 2017-05-07 16:08:05 +02:00
Sei Lisa
7110802dab Fix incorrect explanation of the effect of multiple labels in LSO. 2017-05-06 16:19:42 +02:00
Sei Lisa
6fe4cc3ae8 Add (undocumented) option 'rsrclimit' to limit resource usage. 2017-05-06 16:17:46 +02:00
Sei Lisa
0af2349ef9 Add command-line options to change default builtins and SEF table files. 2017-04-28 23:43:15 +02:00
Sei Lisa
f0c115f924 Add optimizer option 'listlength' to optimize llGetListLength.
llGetListLength(arg) was transformed to arg!=[] whenever constant folding was active. This option allows disabling that optimization.
2017-01-25 19:22:36 +01:00
Sei Lisa
5fff5f37d0 Expand help text on --prenodef. 2017-01-12 02:03:39 +01:00
Sei Lisa
e5ffe56fec Add command line option -y/--python-exception, revert previous commit.
By default, catch exceptions and report them without a stack trace. When this option is specified, raise an actual Python exception (should show a strack trace).

Note: diff for this patch is best seen with -b (ignore-whitespace-change).
2017-01-12 01:55:52 +01:00
Sei Lisa
26b49b0807 Fix problem with parsing erroneous options that contain UTF-8. 2017-01-11 01:36:24 +01:00
Sei Lisa
8b9fe7693e Change option --scriptname to --shortname and change help text.
Option --scriptname did nothing, because the program expected --shortname instead. --scriptname is far more confusing, given that it's intended as the value that lands in the __SHORTFILE__ macro, so it has been renamed.

Improve the help text regarding that option; also fix the wording for what -O help does and add an example of how to use -O.
2017-01-08 05:23:50 +01:00
Sei Lisa
06edf8f152 Add undocumented -O options 'LSO' and 'Expr'.
For unit testing.
2017-01-04 05:08:09 +01:00
Sei Lisa
35687f1b0f Expand a comment. 2017-01-04 05:07:50 +01:00
Sei Lisa
b8a27bbcd2 Check that the file exists instead of raising an ugly Python exception. 2016-12-26 03:00:22 +01:00
Sei Lisa
e3632d8a64 Create a list of valid optimizer options and check against it.
Validating the input options was badly needed.
2016-12-25 21:34:42 +01:00
Sei Lisa
e2ad14ee1b Fix a few violations of our guidelines for Unicode handling.
Also use e.args[0] instead of e[0].
2016-12-25 20:49:56 +01:00
Sei Lisa
1162c202c4 Give informative error messages when exiting with an error. 2016-12-25 20:47:54 +01:00
Sei Lisa
0137d1ae52 Check -O help only when we're done processing options. 2016-12-25 20:43:24 +01:00
Sei Lisa
32840f4ad6 Add Clear to --optimizer-options, to unset all options. 2016-12-25 20:40:15 +01:00
Sei Lisa
b76063821b Check for valid UTF-8 unconditionally.
The input script must be encoded in UTF-8. We had a check that was only activated when the preprocessor was called. Activate it always, as not doing so triggers an unhandled exception later on.
2016-12-25 20:29:43 +01:00
Sei Lisa
6f474c09d2 Fix wording of WarnTabs option
When we changed 'nofoldtabs' to 'warntabs', we changed the meaning to the opposite. However, the wording was still the old one. Make it right.
2016-12-25 19:21:16 +01:00
Sei Lisa
505f7777d4 Pass command line arguments to main function.
As opposed to reading them from sys.argv. That will facilitate unit testing of main() later.
2016-12-25 01:12:17 +01:00
Sei Lisa
39261cbfc8 Make Unicode some strings that should be, and improve error reporting in builtins.txt
Also work towards the convention that strings that represent text (possibly translatable) are in double quotes, not single.
2016-12-20 20:13:53 +01:00
Sei Lisa
a041faa7a8 Bump version. 2016-06-28 03:51:43 +02:00
Sei Lisa
980adff9c8 Make the -O options case-insensitive. 2016-06-28 03:45:39 +02:00
Sei Lisa
0c3ad9b938 Change skippreproc -> processpre, add #pragma option processing.
Usage:

Options are case insensitive.
2016-06-28 03:20:21 +02:00
Sei Lisa
6b45d4efcf Add comment on the validity of the RE for detecting certain defines. 2016-06-27 21:03:18 +02:00
Sei Lisa
79dff25769 Update copyright years of some files; add legalese to seftable.txt 2016-06-27 20:06:41 +02:00