Commit graph

84 commits

Author SHA1 Message Date
Sei Lisa
ceb442e931 Improve error reporting, by printing the errored line and a caret (^), taking care to display the beginning of the token the error is at. 2016-01-02 03:39:47 +01:00
Sei Lisa
0122d6ed70 On second thought, disable explicitcast for list+nonlist and nonlist+list entirely, as they are not the same as list+(list)nonlist and (list)nonlist+list anyway. 2015-09-05 03:09:46 +02:00
Sei Lisa
d8649deebd nonlist + list was returning the type of the nonlist element. Fixed and added a
regression test.

Funnily enough, it was correct if explicit cast was active. Removed from explicit cast now that it's active for all.
2015-09-04 05:56:05 +02:00
Sei Lisa
1a67db64dc Get rid of builtins.txt.dat by adding a parameter to the parser ctor. 2015-07-09 20:35:14 +02:00
Sei Lisa
1160fea8cf Fix extendedtypecast problem with negative constants after typecasts. 2015-06-23 06:54:04 +02:00
Sei Lisa
52ebe20a67 Refine a comment 2015-06-17 02:31:58 +02:00
Sei Lisa
bfabcd16db Fix parser bug where list = anytype was accepted. Fix also the test suite. 2015-06-16 04:16:59 +02:00
Sei Lisa
faf296fa74 Fix bug with scripts that have UTF-8 characters.
The parser expects bytes, not unicode.
2015-05-03 05:19:14 +02:00
Sei Lisa
4fbbda60a7 Elaborate on the TODO. 2015-03-28 23:34:07 +01:00
Sei Lisa
b8a7e88f1a Add TODO item 2015-03-28 23:31:11 +01:00
Sei Lisa
edbc240408 Remove 'Local' from symbol table; add note about an unimplemented feature; improve symbol table documentation; rename a helper variable. 2015-03-27 02:12:32 +01: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
3839863a21 EInternal is no longer reused. 2015-03-26 23:26:36 +01:00
Sei Lisa
e21173170e Simplify the builtins.txt parser REs by checking the types in the code.
Gives us more granularity reporting errors.
2015-03-26 23:08:54 +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
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
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
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
a292846d28 Fix missing scope table index when generating the call to lazy_list_set. 2015-03-07 14:50: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
c68a1f4ad6 Add copyright notices to all files, to prepare the program for release. 2015-03-05 23:18:41 +01:00
Sei Lisa
33de6c0efc Comment typo, brackets->braces. 2015-03-05 20:18:13 +01:00
Sei Lisa
308ca7c8ff Add support for 'break n;' and 'continue n;'. Also simplify the break/continue stacks handling code and fix some bugs. 2015-03-05 20:12:32 +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
a36715f121 Add reference source, comments. 2015-03-04 02:01:03 +01:00
Sei Lisa
8b9676e5dc Fix missing 'paramscope', remove commented out old body, simplify. 2015-03-04 01:51:08 +01:00
Sei Lisa
a6127cf144 lazylistcompat idea ditched. 2015-03-04 00:40:07 +01:00
Sei Lisa
8ea6ae50fd Replace the lazy_list_set function with a more compact one. 2015-03-03 20:00: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
22a1a2e8ba Document the change to the symtab structure. 2015-03-03 00:51:48 +01:00
Sei Lisa
01f2bba2f4 Make *-2 and *2 only work for local variables. Needed an adition to the parser. 2015-03-03 00:49:14 +01:00
Sei Lisa
1dea1bd12c Make parentheses no longer explicit in the AST (Beta).
The output module adds parentheses where necessary, depending on the evaluation order in the tree. Or that's the idea. Prone to bugs, let's see how it bodes.
2015-02-28 00:43:26 +01:00
Sei Lisa
4c08b7173a minor clarification of comment 2015-02-27 04:46:23 +01:00
Sei Lisa
0a0e5926d5 Fix bug where negative signs of global integers weren't being output. 2015-02-12 04:23:47 +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
e89869a563 Add TODOs 2014-12-13 13:12:02 +01:00
Sei Lisa
ed4b963356 Rename _ops to _toks to eliminate ambiguity and facilitate a future merge. 2014-08-13 13:34:09 +02:00
Sei Lisa
0d81f132ab Fix bug where the assigned type was not checked in declarations. 2014-08-10 00:44:57 +02:00
Sei Lisa
7a4a6d221e Fix field assignment. Add regression test. 2014-08-08 00:52:23 +02:00
Sei Lisa
a03e0261ff Add TODO 2014-08-06 22:49:57 +02:00
Sei Lisa
9c4d81db08 Implement side-effect-free (SEF) analysis. Also optimize x++ to ++x.
As an additional bonus, the condition folding function is now the one that converts a condition to -1, relieving that burden from the rest of the code and simplifying tests.
2014-08-06 04:30:26 +02:00
Sei Lisa
0a7d409a4e Report errors at EOL as errors at next line. 2014-08-06 04:12:44 +02:00
Sei Lisa
8d1e819771 Cosmetic changes: docstring style; remove commented code. 2014-08-06 04:11:57 +02:00