Commit graph

126 commits

Author SHA1 Message Date
Sei Lisa
d03de9a6be Add --blacklist, to blacklist constants; defauls to NAK,JSON_*
Closes #30, but not the general problem of control characters in the source.
2024-05-28 20:19:10 +02:00
Sei Lisa
f854e94349 New copyright year 2024-04-14 11:40:21 +02:00
Sei Lisa
231c16b90e New copyright year 2023-02-03 13:06:18 +01:00
Sei Lisa
642f8e995d Fix missing comma that prevented --libdata from working
It doesn't seem to be much used, considering it's broken since revision 0af2349e where the feature was first introduced, and it hasn't been reported.
2022-12-20 21:49:32 +01:00
Sei Lisa
08c429f22b Add IfElseSwap option
This enables an option that was being done unconditionally: to swap the `if` and `else` branches if the condition is shorter when negated.

Enabled by default.
2022-10-31 20:08:26 +01:00
Sei Lisa
52771ce630 Add pperrors variable to ease rebasing the preprocessor branch 2022-06-17 16:13:49 +02:00
Sei Lisa
7eaa4cb0ad Fix --postarg and add option --preproc-show-cmdline + unit test
Thanks to @Blues-Today for reporting that --postarg was not working.

This needed a regression test, and the best way to distinguish --prearg from --postarg is to display the full preprocessor command line, therefore a new option was added for that purpose: --preproc-show-cmdline

Fixes #18.
2022-06-17 16:13:22 +02:00
Sei Lisa
8d413f910e Forgot to update copyright year 2022-06-07 19:46:31 +02:00
Sei Lisa
81906475ff Update copyright year 2021-01-05 23:27:21 +01:00
Sei Lisa
e1bcccb979 All tests pass now 2020-11-10 02:14:15 +01:00
Sei Lisa
16d8c4c9d1 More progress in migration to dual Python 2&3. Just 2 tests left. 2020-11-10 00:15:48 +01:00
Sei Lisa
f8cf78dfac Progress towards dual Python 2 & 3 2020-11-09 02:28:57 +01:00
Sei Lisa
4fd4bf71aa Use frozenset more consistently 2020-11-09 02:11:35 +01:00
Sei Lisa
d9938f1a37 Misc small non-user-visible fixes
Some are Unicode vs Str stuff, others are style adjustments, others in unused functions, and so on.
2020-11-09 02:00:40 +01:00
Sei Lisa
234b9b23a3 Bump copyright year 2020-04-23 00:38:20 +02:00
Sei Lisa
2408e6e6fe Raise resource limits; raise them again in case of exception
The limits were too low to be reasonable with more modern versions of Python.

Double exceptions were possible. Make use of soft/hard limits; raise the soft limit in case of exception. That should make it less likely to get a double exception.

Per bug report by @LeonaMorro (thanks!)

Fixes GitHub issue report #9 (fix #9).
2019-10-11 20:15:52 +02:00
Sei Lisa
3cfbbb923c The encoding of sys.stderr can exist and be None. 2019-05-01 01:22:54 +02:00
Sei Lisa
2ade2804df Bug fix: include 'emap' attribute in UniConvScript
Fixes an AttributeError: 'UniConvScript' object has no attribute 'emap'
2019-02-04 19:03:46 +01:00
Sei Lisa
68c8726a64 Option to output error messages suitable for automated processing
Enables use of the optimizer as an editor plug-in.
2019-02-04 17:20:12 +01:00
Sei Lisa
fba40123e1 Only include BOM if it isn't already present. 2019-01-17 12:55:49 +01:00
Sei Lisa
b5092c0be2 More Unicode vs str fixes 2019-01-16 20:24:31 +01:00
Sei Lisa
173a12be15 New feature: add preprocessor params before or after system's
Reverts f958b1cdf9, and adds the possibility of adding parameters after the system-inserted ones through a new command line parameter -A/--postarg.

Enables using e.g. both a command interpreter which requires the file to execute before any other parameters, and overriding the default definitions.
2019-01-16 19:19:27 +01:00
Sei Lisa
44ba2e2a8a Add digraph support to the default mcpp command line 2019-01-16 19:05:24 +01:00
Sei Lisa
fe2dd9a721 First baby steps towards dual Python2+3 compatibility 2019-01-16 00:15:06 +01:00
Sei Lisa
01d45191ae Minor fixes in encoding handling
This actually needs a complete overhaul, factorization et al.
2019-01-13 00:25:28 +01:00
Sei Lisa
f958b1cdf9 Append --preargs options at the end of the command line
Allows the user to override default defines, for example.

Also add docstring to PreparePreproc().
2019-01-12 21:16:35 +01:00
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