@@ -2,6 +2,7 @@ import { BraceExpression, CompileStatement, CompilerError, ExportStatement, Expr
22import { CodeAction , CodeActionKind , Range } from 'lsp-types' ;
33import { dictionary } from './dictionary/dictionary.js' ;
44import levenshtein from 'js-levenshtein' ;
5+ import { subRange } from './diagnostic.js' ;
56
67const caf = {
78 mk : ( keyword : string , program : ProgramStatement , range : Range , filePath : string ) : CodeAction [ ] => {
@@ -17,7 +18,7 @@ const caf = {
1718 edit : {
1819 changes : {
1920 [ filePath ] : [ {
20- range,
21+ range : subRange ( range ) ,
2122 newText : word
2223 } ]
2324 }
@@ -485,6 +486,13 @@ export namespace syxparser {
485486 else if ( tt === TokenType . OpenSquare ) return parseSquareExpression ( put , defaultRange ) ;
486487 else if ( tt === TokenType . OpenParen ) return parseParenExpression ( put , defaultRange ) ;
487488 else if ( tt === TokenType . Identifier && at ( 1 ) . type === TokenType . VarSeperator ) return parsePrimitiveVariable ( put ) ;
489+ else if ( keywords . includes ( tt ) ) {
490+ if ( ! statements ) throw new CompilerError ( at ( ) . range , 'Statement not allowed here.' , filePath ) ;
491+ return parseStatement ( ) ;
492+ } else if ( tt === TokenType . Identifier && expectIdentifier ) {
493+ const { value, range } = tokens . shift ( ) ;
494+ return node ( { type : NodeType . String , value, range } , put ) ;
495+ }
488496 else throw new CompilerError ( at ( ) . range , `Unexpected expression: '${ at ( ) . value } '` , filePath ) ;
489497
490498
0 commit comments