aboutsummaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-10 15:27:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-10 15:27:17 -0300
commit4b107a87760ee5f85185a904c9088ca476b94be5 (patch)
treee3808cb7a4fc09a14b5b0b6756ea1ac2cddcbf42 /lparser.c
parent429761d7d29226dd0c220de9fdc7c28ea54d95c0 (diff)
downloadlua-4b107a87760ee5f85185a904c9088ca476b94be5.tar.gz
lua-4b107a87760ee5f85185a904c9088ca476b94be5.tar.bz2
lua-4b107a87760ee5f85185a904c9088ca476b94be5.zip
Details in lparser.c
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.)
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/lparser.c b/lparser.c
index 6022b38e..036f133b 100644
--- a/lparser.c
+++ b/lparser.c
@@ -797,10 +797,11 @@ static void close_func (LexState *ls) {
797} 797}
798 798
799 799
800 800/*
801/*============================================================*/ 801** {======================================================================
802/* GRAMMAR RULES */ 802** GRAMMAR RULES
803/*============================================================*/ 803** =======================================================================
804*/
804 805
805 806
806/* 807/*
@@ -974,15 +975,15 @@ static void constructor (LexState *ls, expdesc *t) {
974 init_exp(t, VNONRELOC, fs->freereg); /* table will be at stack top */ 975 init_exp(t, VNONRELOC, fs->freereg); /* table will be at stack top */
975 luaK_reserveregs(fs, 1); 976 luaK_reserveregs(fs, 1);
976 init_exp(&cc.v, VVOID, 0); /* no value (yet) */ 977 init_exp(&cc.v, VVOID, 0); /* no value (yet) */
977 checknext(ls, '{'); 978 checknext(ls, '{' /*}*/);
978 cc.maxtostore = maxtostore(fs); 979 cc.maxtostore = maxtostore(fs);
979 do { 980 do {
980 lua_assert(cc.v.k == VVOID || cc.tostore > 0); 981 lua_assert(cc.v.k == VVOID || cc.tostore > 0);
981 if (ls->t.token == '}') break; 982 if (ls->t.token == /*{*/ '}') break;
982 closelistfield(fs, &cc); 983 closelistfield(fs, &cc);
983 field(ls, &cc); 984 field(ls, &cc);
984 } while (testnext(ls, ',') || testnext(ls, ';')); 985 } while (testnext(ls, ',') || testnext(ls, ';'));
985 check_match(ls, '}', '{', line); 986 check_match(ls, /*{*/ '}', '{' /*}*/, line);
986 lastlistfield(fs, &cc); 987 lastlistfield(fs, &cc);
987 luaK_settablesize(fs, pc, t->u.info, cc.na, cc.nh); 988 luaK_settablesize(fs, pc, t->u.info, cc.na, cc.nh);
988} 989}
@@ -1080,7 +1081,7 @@ static void funcargs (LexState *ls, expdesc *f) {
1080 check_match(ls, ')', '(', line); 1081 check_match(ls, ')', '(', line);
1081 break; 1082 break;
1082 } 1083 }
1083 case '{': { /* funcargs -> constructor */ 1084 case '{' /*}*/: { /* funcargs -> constructor */
1084 constructor(ls, &args); 1085 constructor(ls, &args);
1085 break; 1086 break;
1086 } 1087 }
@@ -1167,7 +1168,7 @@ static void suffixedexp (LexState *ls, expdesc *v) {
1167 funcargs(ls, v); 1168 funcargs(ls, v);
1168 break; 1169 break;
1169 } 1170 }
1170 case '(': case TK_STRING: case '{': { /* funcargs */ 1171 case '(': case TK_STRING: case '{' /*}*/: { /* funcargs */
1171 luaK_exp2nextreg(fs, v); 1172 luaK_exp2nextreg(fs, v);
1172 funcargs(ls, v); 1173 funcargs(ls, v);
1173 break; 1174 break;
@@ -1215,7 +1216,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
1215 init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 0, 1)); 1216 init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 0, 1));
1216 break; 1217 break;
1217 } 1218 }
1218 case '{': { /* constructor */ 1219 case '{' /*}*/: { /* constructor */
1219 constructor(ls, v); 1220 constructor(ls, v);
1220 return; 1221 return;
1221 } 1222 }
@@ -1922,6 +1923,8 @@ static void statement (LexState *ls) {
1922 1923
1923/* }====================================================================== */ 1924/* }====================================================================== */
1924 1925
1926/* }====================================================================== */
1927
1925 1928
1926/* 1929/*
1927** compiles the main function, which is a regular vararg function with an 1930** compiles the main function, which is a regular vararg function with an