aboutsummaryrefslogtreecommitdiff
path: root/lparser.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Global initialization checks name conflictRoberto I2025-11-081-3/+16
| | | | | Initialization "global a = 10" raises an error if global 'a' is already defined, that is, it has a non-nil value.
* Vertical bar removed from syntax of vararg tableRoberto I2025-10-301-2/+2
| | | | | | The syntax 'function foo (a, b, ...arg)' is already used by JavaScript for this same semantics, so it seems natural to use the same notation in Lua.
* Fixed initialization of global variablesRoberto I2025-10-291-12/+29
| | | | | | | | When calling 'luaK_storevar', the 'expdesc' for the variable must be created before the one for the expression, to satisfy the assumptions for register allocation. So, in a statement like 'global a = exp', where 'a' is actually '_ENV.a', this variable must be handled before the initializing expression 'exp'.
* Initialization of too many locals break assertionRoberto I2025-10-101-0/+1
| | | | | | The check for limit of local variables is made after generating code to initialize them. If there are too many local variables not initialized, the coding of instruction OP_LOADNIL could overflow an argument.
* Optimization for vararg tablesRoberto I2025-09-241-2/+8
| | | | | | | A vararg table can be virtual. If the vararg table is used only as a base in indexing expressions, the code does not need to create an actual table for it. Instead, it compiles the indexing expressions into direct accesses to the internal vararg data.
* Varag parameter is a new kind of variableRoberto I2025-09-171-9/+17
| | | | To allow some optimizations on its use.
* Vararg tableRoberto I2025-09-161-10/+19
| | | | Not yet optimized nor documented.
* Added limit to number of elements in a constructorRoberto I2025-08-271-3/+18
| | | | | The reasoning in commit 519c57d5 is wrong: A sequence of nils generates several fields with just one OP_LOADNIL.
* DetailsRoberto I2025-08-091-1/+1
|
* Optional initialization for global declarationsRoberto Ierusalimschy2025-07-081-23/+58
|
* No need to limit variable declarations to 250Roberto Ierusalimschy2025-06-181-3/+2
| | | | Only local variables, which use registers, need this low limit.
* Removed uneeded check in parserRoberto Ierusalimschy2025-06-041-1/+0
| | | | | | | | | In a constructor, each field generates at least one opcode, and the number of opcodes is limited by INT_MAX. Therefore, the counters for number of fields cannot exceed this limit. (The current limit for items in the hash part of a table has a limit smaller than INT_MAX. However, as long as there are no overflows, the logic for table resizing will handle that limit.)
* Bug: check for constructor overflow in [exp] fieldsRoberto Ierusalimschy2025-05-201-3/+2
| | | | | The check for constructor overflow was considering only fields with explicit names, ignoring fields with syntax '[exp]=exp'.
* New way to control preambular declarationRoberto Ierusalimschy2025-05-201-13/+20
| | | | | Validity of the preambular global declaration in controled together with all declarations, when checking variable names.
* Proper error message when jumping into 'global *'Roberto Ierusalimschy2025-05-181-3/+3
| | | | | | A goto cannot jump into the scope of any variable declaration, including 'global *'. To report the error, it needs a "name" for the scope it is entering.
* Variable attributes can prefix name listRoberto Ierusalimschy2025-05-181-22/+31
| | | | | In this format, the attribute applies to all names in the list; e.g. "global<const> print, require, math".
* Slightly faster way to check for "global"Roberto Ierusalimschy2025-05-161-2/+2
|
* Internalized string "break" kept by the parserRoberto Ierusalimschy2025-05-151-3/+3
| | | | | | The parser uses "break" as fake label to compile "break" as "goto break". To avoid producing this string at each use, it keeps it available in its state.
* Remove compat code in parser when not neededRoberto Ierusalimschy2025-05-131-1/+4
|
* Collective declaration for globals ('global *')Roberto Ierusalimschy2025-05-131-19/+36
|
* Correct line in error message for constant functionRoberto Ierusalimschy2025-05-121-1/+1
|
* 'expdesc' doesn't depend on 'actvar' for var. info.Roberto Ierusalimschy2025-05-111-8/+7
| | | | | In preparation for 'global *', the structure 'expdesc' does not point to 'actvar.arr' for information about global variables.
* Janitorial work on castsRoberto Ierusalimschy2025-05-081-2/+2
|
* New syntax 'global function'Roberto Ierusalimschy2025-05-081-10/+39
|
* Checks for read-only globalsRoberto Ierusalimschy2025-05-061-6/+18
|
* First implementation of global declarationsRoberto Ierusalimschy2025-05-051-33/+78
|
* Details (typos in comments)Roberto Ierusalimschy2025-04-231-1/+1
|
* Function 'luaK_semerror' made varargRoberto Ierusalimschy2025-04-171-18/+12
| | | | | All calls to 'luaK_semerror' were using 'luaO_pushfstring' to create the error messages.
* Fixed conversion warnings from clangRoberto Ierusalimschy2025-01-141-1/+1
| | | | | Plus some other details. (Option '-Wuninitialized' was removed from the makefile because it is already enabled by -Wall.)
* Error "break outside loop" made a syntax errorRoberto Ierusalimschy2025-01-131-11/+14
| | | | Syntax errors are easier to handle than semantic errors.
* Details in lparser.cRoberto Ierusalimschy2025-01-101-10/+13
| | | | | | Added comments so that all braces pair correctly. (The parser has several instances of unmatched braces as characters ('{' or '}'), which hinders matching regular braces in the code.)
* Another way to compile goto'sRoberto Ierusalimschy2025-01-101-107/+80
| | | | | | | | | | | | The compilation of a goto or a label just create an entry and generate boilerplate code for the gotos. As we don't know yet whether it needs a CLOSE, we code a jump followed by a CLOSE, which is then dead code. When a block ends (and then we know for sure whether there are variables that need to be closed), we check the goto's against the labels of that block. When closing a goto against a label, if it needs a CLOSE, the compiler swaps the order of the jump and the CLOSE, making the CLOSE active.
* Scanner and parser use different tables for constantsRoberto Ierusalimschy2024-12-171-1/+6
| | | | | | | | | | Moreover, each function being parsed has its own table. The code is cleaner when each table is used for one specific purpose: The scanner uses its table to anchor and unify strings, mapping strings to themselves; the parser uses it to reuse constants in the code, mapping constants to their indices in the constant table. A different table for each task avoids false collisions.
* USHRT_MAX changed to SHRT_MAXRoberto Ierusalimschy2024-09-191-1/+1
| | | | USHRT_MAX does not fit in an 'int' in 16-bit systems.
* 'lcode.c' can use 'checklimit', tooRoberto Ierusalimschy2024-08-201-5/+5
|
* Added gcc option '-Wconversion'Roberto Ierusalimschy2024-07-271-16/+18
| | | | | No warnings for standard numerical types. Still pending alternative numerical types.
* New instruction format for SETLIST/NEWTABLERoberto Ierusalimschy2024-06-281-1/+1
| | | | | | New instruction format 'ivABC' (a variant of iABC where parameter vC has 10 bits) allows constructors of up to 1024 elements to be coded without EXTRAARG.
* Flexible limit for use of registers by constructorsRoberto Ierusalimschy2024-06-271-2/+19
| | | | | | | | Instead of a fixed limit of 50 registers (which, in a bad worst case, can limit the nesting of constructors to 5 levels), the compiler computes an individual limit for each constructor based on how many registers are available when it runs. This limit then controls the frequency of SETLIST instructions.
* Cleaning of llimits.hRoberto Ierusalimschy2024-06-201-1/+1
| | | | | | Several definitions that don't need to be "global" (that is, that concerns only specific parts of the code) moved out of llimits.h, to more appropriate places.
* New macro 'getlstr'Roberto Ierusalimschy2023-08-301-2/+4
| | | | Accesses content and length of a 'TString'.
* Field 'Proto.is_vararg' uses only one bitRoberto Ierusalimschy2023-08-301-2/+2
| | | | So that the other bits can be used for other purposes.
* Merge branch 'master' into nextversionRoberto Ierusalimschy2023-08-231-6/+6
|\
| * Bug: Wrong line number for function callsRoberto Ierusalimschy2023-08-231-6/+6
| |
* | Merge branch 'master' into nextversionRoberto Ierusalimschy2023-06-221-4/+4
|\|
| * Detailsv5.4.5Roberto Ierusalimschy2023-04-181-4/+4
| | | | | | | | Typos in comments and details in the manual.
* | Changes in opcodes for generic 'for'Roberto Ierusalimschy2022-12-221-12/+11
| | | | | | | | | | Again, as the control variable is read only, the code doesn't need to keep an internal copy of it.
* | Simplification in opcodes for numerical 'for'Roberto Ierusalimschy2022-12-211-2/+2
| | | | | | | | | | As the control variable is read only, the code doesn't need to keep an internal copy of it.
* | Control variables in for loops are read onlyRoberto Ierusalimschy2022-12-211-11/+19
|/
* Stack indices changed to union'sRoberto Ierusalimschy2022-10-291-3/+3
| | | | | That will allow to change pointers to offsets while reallocating the stack.
* Bug: 'break' may not properly close variable in a 'for' loopRoberto Ierusalimschy2022-08-241-8/+8
| | | | | | | Function 'leaveblock' was generating "break" label before removing variables from the closing block. If 'createlabel' created a 'close' instruction (which it did when matching a goto/break that exited the scope of an upvalue), that instruction would use the wrong level.