From 418f110d9a55414c1f03af2d6305ae36175533d9 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sun, 26 Jan 2025 13:51:11 -0500 Subject: [PATCH] Split LO Calc sheet refs And fix some suffixes --- LibreOffice Calc Formula.sublime-syntax | 56 ++++++++----- tests/syntax_test_libre_references.localc.txt | 83 ++++++++++++------- 2 files changed, 88 insertions(+), 51 deletions(-) diff --git a/LibreOffice Calc Formula.sublime-syntax b/LibreOffice Calc Formula.sublime-syntax index d54ffdf..f3c6717 100644 --- a/LibreOffice Calc Formula.sublime-syntax +++ b/LibreOffice Calc Formula.sublime-syntax @@ -17,45 +17,59 @@ contexts: push: function-call-body sheet-reference: - - match: (?=\$?{{sheet}}[!\.]) + - match: \$(?={{sheet}}\.) + scope: punctuation.definition.annotation.begin.libre + push: sheet-reference-body-dollar + - match: (?={{sheet}}!) push: sheet-reference-body - sheet-reference-body: - - meta_scope: meta.reference.sheet - - match: '[!\.]' - scope: punctuation.separator.sequence.sheet + sheet-reference-body-dollar: + - meta_scope: meta.reference.sheet.libre + - match: \. + scope: punctuation.separator.sequence.libre pop: 1 - - match: \$ + - include: sheet-reference-quoted + - match: '{{sheet}}' + scope: entity.name.struct.sheet.libre + - include: immediately-pop + + sheet-reference-body: + - meta_scope: meta.reference.sheet.libre + - match: '!' scope: punctuation.separator.sequence.libre + pop: 1 + - include: sheet-reference-quoted + - match: '{{sheet}}' + scope: entity.name.struct.sheet.libre + - include: immediately-pop + + sheet-reference-quoted: - match: \' - scope: punctuation.definition.annotation.begin.sheet + scope: punctuation.definition.annotation.begin.libre push: - - meta_content_scope: entity.name.struct.sheet + - meta_content_scope: entity.name.struct.sheet.libre - match: \'\' - scope: constant.character.escape.sheet + scope: constant.character.escape.libre - match: \'(?=[!\.]) - scope: punctuation.definition.annotation.end.sheet + scope: punctuation.definition.annotation.end.libre pop: 1 - - match: '{{sheet}}' - scope: entity.name.struct.sheet - - include: immediately-pop cell-or-range-reference: - meta_append: true - match: ({{rc}})(:)({{rc}}) - scope: meta.reference.range.cell.sheet + scope: meta.reference.range.cell.libre captures: - 1: storage.type.sheet - 2: punctuation.separator.sequence.sheet - 3: storage.type.sheet + 1: storage.type.libre + 2: punctuation.separator.sequence.libre + 3: storage.type.libre push: after-reference - match: ({{rc}}) - scope: meta.reference.range.cell.sheet + scope: meta.reference.range.cell.libre captures: - 1: storage.type.sheet - 2: punctuation.separator.sequence.sheet - 3: storage.type.sheet + 1: storage.type.libre + 2: punctuation.separator.sequence.libre + 3: storage.type.libre push: after-reference variables: diff --git a/tests/syntax_test_libre_references.localc.txt b/tests/syntax_test_libre_references.localc.txt index b5c36ae..14ac2a9 100644 --- a/tests/syntax_test_libre_references.localc.txt +++ b/tests/syntax_test_libre_references.localc.txt @@ -34,32 +34,35 @@ ='John''sSheetDon''tTouch'!A1 ='s''s'!N36 -'^^^^^^^ meta.reference.sheet -'^ punctuation.definition.annotation.begin.sheet - entity -' ^^^^ entity.name.struct.sheet -' ^^ constant.character.escape.sheet -' ^ punctuation.definition.annotation.end.sheet - entity -' ^ punctuation.separator.sequence.sheet +'^^^^^^^^^^ meta.reference - meta.reference meta.reference +'^^^^^^^ meta.reference.sheet.libre +'^ punctuation.definition.annotation.begin.libre - entity +' ^^^^ entity.name.struct.sheet.libre +' ^^ constant.character.escape.libre +' ^ punctuation.definition.annotation.end.libre - entity +' ^ punctuation.separator.sequence.libre ' ^^^ meta.reference.cell.sheet storage.type.sheet ='s''''s'!N36 -'^^^^^^^^^ meta.reference.sheet -'^ punctuation.definition.annotation.begin.sheet - entity +'^^^^^^^^^^^^ meta.reference - meta.reference meta.reference +'^^^^^^^^^ meta.reference.sheet.libre +'^ punctuation.definition.annotation.begin.libre - entity ' ^^^^^^ entity.name.struct.sheet -' ^^^^ constant.character.escape.sheet -' ^ punctuation.definition.annotation.end.sheet - entity -' ^ punctuation.separator.sequence.sheet +' ^^^^ constant.character.escape.libre +' ^ punctuation.definition.annotation.end.libre - entity +' ^ punctuation.separator.sequence.libre ' ^^^ meta.reference.cell.sheet storage.type.sheet =한국어!L11 ' <- keyword.operator.assignment -'^^^^^^^ meta.reference - meta meta -' ^ - meta.reference -'^^^ entity.name.struct -' ^ punctuation.separator.sequence -' ^^^ storage.type +'^^^^^^^ meta.reference - meta.reference meta.reference +'^^^^ meta.reference.sheet.libre +'^^^ entity.name.struct.sheet.libre +' ^ punctuation.separator.sequence.libre +' ^^^ meta.reference.cell.sheet storage.type.sheet =_hello_2world!N36 +'^^^^^^^^^^^^^^^^^ meta.reference - meta.reference meta.reference ' <- keyword.operator.assignment '^^^^^^^^^^^^^^^^^ meta.reference - meta meta ' ^ - meta.reference @@ -67,32 +70,52 @@ ' ^ punctuation.separator.sequence - entity ='This''sASheetWithAnEscapedSingleQuote'!A1 -'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference.sheet - meta meta -'^ punctuation.definition.annotation.begin.sheet - entity +'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference - meta.reference meta.reference +'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference.sheet.libre - meta meta +'^ punctuation.definition.annotation.begin.libre - entity ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.sheet -' ^^ constant.character.escape.sheet -' ^ punctuation.definition.annotation.end.sheet - entity -' ^ punctuation.separator.sequence.sheet +' ^^ constant.character.escape.libre +' ^ punctuation.definition.annotation.end.libre - entity +' ^ punctuation.separator.sequence.libre ' ^^ meta.reference.cell.sheet storage.type.sheet ' <- keyword.operator.assignment.sheet =''''!A1 -'^^^^^ meta.reference.sheet -'^ punctuation.definition.annotation.begin.sheet -' ^^ entity.name.struct.sheet constant.character.escape.sheet - punctuation -' ^ punctuation.definition.annotation.end.sheet -' ^ punctuation.separator.sequence.sheet +'^^^^^^^ meta.reference - meta.reference meta.reference +'^^^^^ meta.reference.sheet.libre +'^ punctuation.definition.annotation.begin.libre +' ^^ entity.name.struct.sheet.libre constant.character.escape.libre - punctuation +' ^ punctuation.definition.annotation.end.libre +' ^ punctuation.separator.sequence.libre ' ^^ meta.reference.cell.sheet storage.type.sheet ' <- keyword.operator.assignment.sheet ='^'!A1 +'^^^^^^ meta.reference - meta.reference meta.reference '^^^^ meta.reference.sheet -'^ punctuation.definition.annotation.begin.sheet -' ^ entity.name.struct.sheet -' ^ punctuation.definition.annotation.end.sheet -' ^ punctuation.separator.sequence.sheet +'^ punctuation.definition.annotation.begin.libre +' ^ entity.name.struct.sheet.libre +' ^ punctuation.definition.annotation.end.libre +' ^ punctuation.separator.sequence.libre ' ^^ meta.reference.cell.sheet storage.type.sheet '''[ LIBRE REFERENCES ]'''''''''''''''''''''''''''''''''''''''''''''''''' +=$_hello_2world.A1 +'^^^^^^^^^^^^^^^^^ meta.reference - meta.reference meta.reference +'^^^^^^^^^^^^^^^ meta.reference.sheet.libre +'^ punctuation.definition.annotation.begin.libre +' ^^^^^^^^^^^^^ entity.name.struct.sheet.libre +' ^ punctuation.separator.sequence.libre +' ^^ meta.reference.cell.sheet storage.type.sheet + =$'John''sSheetDon''tTouch'.A1 +'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference - meta.reference meta.reference +'^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference.sheet.libre +'^^ punctuation.definition.annotation.begin.libre +' ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.sheet.libre +' ^^ constant.character.escape.libre +' ^^ constant.character.escape.libre +' ^ punctuation.definition.annotation.end.libre +' ^ punctuation.separator.sequence.libre +' ^^ meta.reference.cell.sheet storage.type.sheet