diff --git a/libs/natparse/src/main/java/org/amshove/natparse/lexing/Lexer.java b/libs/natparse/src/main/java/org/amshove/natparse/lexing/Lexer.java index 786592a7f..4d9018d76 100644 --- a/libs/natparse/src/main/java/org/amshove/natparse/lexing/Lexer.java +++ b/libs/natparse/src/main/java/org/amshove/natparse/lexing/Lexer.java @@ -727,6 +727,11 @@ private void consumeAsteriskOrSystemVariable() createAndAdd(SyntaxKind.CURRENT_UNIT); return; } + if (scanner.advanceIfIgnoreCase("CURSOR")) + { + createAndAdd(SyntaxKind.CURSOR); + return; + } if (scanner.advanceIfIgnoreCase("CURS-COL")) { createAndAdd(SyntaxKind.CURS_COL); diff --git a/libs/natparse/src/main/java/org/amshove/natparse/lexing/SyntaxKind.java b/libs/natparse/src/main/java/org/amshove/natparse/lexing/SyntaxKind.java index 47e353037..708f1317d 100644 --- a/libs/natparse/src/main/java/org/amshove/natparse/lexing/SyntaxKind.java +++ b/libs/natparse/src/main/java/org/amshove/natparse/lexing/SyntaxKind.java @@ -370,7 +370,7 @@ public enum SyntaxKind COUPLED(true, false, false), CS(true, false, false), CURRENT(true, false, false), - CURSOR(true, false, false), + CURSOR(true, true, false), CV(false, false, false), DATA(true, false, false), DATAAREA(true, false, false), diff --git a/libs/natparse/src/main/java/org/amshove/natparse/natural/builtin/BuiltInFunctionTable.java b/libs/natparse/src/main/java/org/amshove/natparse/natural/builtin/BuiltInFunctionTable.java index 6b41a32c9..0e716918c 100644 --- a/libs/natparse/src/main/java/org/amshove/natparse/natural/builtin/BuiltInFunctionTable.java +++ b/libs/natparse/src/main/java/org/amshove/natparse/natural/builtin/BuiltInFunctionTable.java @@ -147,6 +147,11 @@ public class BuiltInFunctionTable If you want to get all line numbers, including the `INCLUDE`s, use `*LINEX` instead. """, INTEGER, 4.0), unmodifiableVariable(SyntaxKind.ERROR_LINE, "Returns the line of the statement that raised an error", NUMERIC, 4), + unmodifiableVariable(SyntaxKind.CURSOR, """ + Position of cursor on input screen at time ENTER or function key is pressed. + + Note: It is recommended that the system variables *CURS-LINE and *CURS-COL be used instead of the *CURSOR command. + """, NUMERIC, 6), unmodifiableVariable(SyntaxKind.CURS_FIELD, """ Returns the identification of the field in which the cursor is positioned" + Can only be used together withe the `POS` function. diff --git a/libs/natparse/src/test/java/org/amshove/natparse/lexing/LexerForSystemVariablesShould.java b/libs/natparse/src/test/java/org/amshove/natparse/lexing/LexerForSystemVariablesShould.java index ba2881506..4ae3bdfe5 100644 --- a/libs/natparse/src/test/java/org/amshove/natparse/lexing/LexerForSystemVariablesShould.java +++ b/libs/natparse/src/test/java/org/amshove/natparse/lexing/LexerForSystemVariablesShould.java @@ -160,6 +160,12 @@ void lexMaxval() assertTokens("*MAXVAL", token(SyntaxKind.MAXVAL, "*MAXVAL")); } + @Test + void lexCursor() + { + assertTokens("*CURSOR", token(SyntaxKind.CURSOR, "*CURSOR")); + } + @Test void lexCursLine() {