Skip to content

Commit 08825fe

Browse files
committed
Fix nonstandard symbol parse
1 parent 63afc95 commit 08825fe

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

gen/com/tang/intellij/lua/comment/lexer/_LuaDocLexer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private static int zzUnpackcmap_top(String packed, int offset, int [] result) {
6565
private static final int [] ZZ_CMAP_BLOCKS = zzUnpackcmap_blocks();
6666

6767
private static final String ZZ_CMAP_BLOCKS_PACKED_0 =
68-
"\11\0\1\1\1\2\1\3\1\1\1\4\22\0\1\5"+
68+
"\11\0\1\1\1\2\1\3\1\4\1\5\22\0\1\1"+
6969
"\14\0\1\6\127\0\1\3\u01a2\0\2\3\326\0\u0100\3";
7070

7171
private static int [] zzUnpackcmap_blocks() {
@@ -149,10 +149,10 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
149149
private static final int [] ZZ_TRANS = zzUnpacktrans();
150150

151151
private static final String ZZ_TRANS_PACKED_0 =
152-
"\1\3\1\4\1\5\1\6\1\7\1\4\1\10\1\11"+
153-
"\1\4\1\5\1\11\1\7\1\12\1\11\10\0\1\4"+
154-
"\3\0\1\4\3\0\1\5\12\0\1\13\1\11\2\0"+
155-
"\1\11\1\0\3\11\1\4\1\0\1\11\1\0\1\12"+
152+
"\1\3\1\4\1\5\1\6\1\4\1\7\1\10\1\11"+
153+
"\1\12\1\5\1\11\1\4\1\7\1\11\10\0\1\4"+
154+
"\2\0\1\4\4\0\1\5\12\0\1\13\2\11\1\0"+
155+
"\1\11\2\0\2\11\1\12\1\0\1\11\1\4\1\0"+
156156
"\1\11";
157157

158158
private static int [] zzUnpacktrans() {

src/main/java/com/tang/intellij/lua/doc.flex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import com.tang.intellij.lua.comment.psi.LuaDocTypes;
3636
EOL="\r"|"\n"|"\r\n"
3737
LINE_WS=[\ \t\f]
3838
WHITE_SPACE=({LINE_WS}|{EOL})+
39-
STRING=[^\r\n\t\f]*
39+
STRING=[^\r\n\f]*
4040
//三个-以上
4141
DOC_DASHES = --+
4242
//Strings

src/main/java/com/tang/intellij/lua/psi/parser/LuaExpressionParser.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ object LuaExpressionParser {
2727

2828
enum class ExprType(val ops: TokenSet) {
2929
// or
30-
T_OR(TokenSet.create(OR)),
30+
T_OR(TokenSet.create(OR, LOGICAL_OR)),
3131
// and
32-
T_AND(TokenSet.create(AND)),
32+
T_AND(TokenSet.create(AND, LOGICAL_AND)),
3333
// < > <= >= ~= ==
34-
T_CONDITION(TokenSet.create(GT, LT, GE, LE, NE, EQ)),
34+
T_CONDITION(TokenSet.create(GT, LT, GE, LE, NE, EQ, NOT_EQ)),
3535
// |
3636
T_BIT_OR(TokenSet.create(BIT_OR)),
3737
// ~
@@ -47,7 +47,7 @@ object LuaExpressionParser {
4747
// * / // %
4848
T_MULTIPLICATIVE(TokenSet.create(MULT, DIV, DOUBLE_DIV, MOD)),
4949
// not # - ~
50-
T_UNARY(TokenSet.create(NOT, GETN, MINUS, BIT_TILDE)),
50+
T_UNARY(TokenSet.create(NOT, GETN, MINUS, BIT_TILDE, LOGICAL_NOT)),
5151
// ^
5252
T_EXP(TokenSet.create(EXP)),
5353
// value expr

src/main/java/com/tang/intellij/lua/psi/parser/LuaStatementParser.kt

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ object LuaStatementParser : GeneratedParserUtilBase() {
3232
DOUBLE_COLON -> parseLabelStatement(b)
3333
GOTO -> parseGotoStatement(b)
3434
BREAK -> parseBreakStatement(b)
35+
CONTINUE -> parseContinueStatement(b)
3536
RETURN -> parseReturnStatement(b, l)
3637
LOCAL -> parseLocalDef(b, l)
3738
FOR -> parseForStatement(b, l)
@@ -201,6 +202,14 @@ object LuaStatementParser : GeneratedParserUtilBase() {
201202
return m
202203
}
203204

205+
private fun parseContinueStatement(b: PsiBuilder): PsiBuilder.Marker {
206+
val m = b.mark()
207+
b.advanceLexer()
208+
209+
doneStat(b, m, CONTINUE_STAT)
210+
return m
211+
}
212+
204213
private fun parseReturnStatement(b: PsiBuilder, l: Int): PsiBuilder.Marker {
205214
val m = b.mark()
206215
b.advanceLexer()
@@ -372,30 +381,41 @@ object LuaStatementParser : GeneratedParserUtilBase() {
372381
NAME_EXPR, INDEX_EXPR -> {
373382
var c = expr
374383
var isAssignment = false
384+
var isCompoundAssignment = false
385+
375386
while (b.tokenType == COMMA) {
376387
isAssignment = true
377388
b.advanceLexer() // ,
378389
expectExpr(b, l + 1)
379390
}
380391

381-
// =
392+
// = (普通赋值)
382393
if (isAssignment) {
383394
c = c.precede()
384395
c.done(VAR_LIST)
385396
expectError(b, ASSIGN) { "'='" }
386397
} else if (b.tokenType == ASSIGN) {
387398
c = c.precede()
388399
c.done(VAR_LIST)
389-
390400
b.advanceLexer()
391401
isAssignment = true
392402
}
403+
// 复合赋值操作符 (+=, -=, *=, 等)
404+
else if (isCompoundAssignOp(b.tokenType)) {
405+
isCompoundAssignment = true
406+
b.advanceLexer() // 消费复合赋值操作符
407+
}
393408

394409
if (isAssignment) {
395410
expectExprList(b, l + 1)
396411
val m = c.precede()
397412
doneStat(b, m, ASSIGN_STAT)
398413
return m
414+
} else if (isCompoundAssignment) {
415+
expectExpr(b, l + 1) // 复合赋值只需要一个表达式
416+
val m = c.precede()
417+
doneStat(b, m, COMPOUND_ASSIGN_STAT)
418+
return m
399419
}
400420
}
401421
}
@@ -420,4 +440,14 @@ object LuaStatementParser : GeneratedParserUtilBase() {
420440
expect(b, SEMI)
421441
done(m, type)
422442
}
443+
444+
// 检查是否为复合赋值操作符
445+
private fun isCompoundAssignOp(tokenType: IElementType?): Boolean {
446+
return when (tokenType) {
447+
PLUS_ASSIGN, MINUS_ASSIGN, MULT_ASSIGN, DIV_ASSIGN,
448+
MOD_ASSIGN, EXP_ASSIGN, DOUBLE_DIV_ASSIGN,
449+
BIT_OR_ASSIGN, BIT_AND_ASSIGN, BIT_LTLT_ASSIGN, BIT_RTRT_ASSIGN -> true
450+
else -> false
451+
}
452+
}
423453
}

0 commit comments

Comments
 (0)