Skip to content

Commit

Permalink
Solve polymorphic/comparison ambiguity (#76)
Browse files Browse the repository at this point in the history
Workaround is to have no space for polymorphic and space for
comparisons. This is consistent with usual formatting in omc.
  • Loading branch information
phannebohm authored Sep 18, 2024
1 parent 729b45a commit c75da5e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions syntaxes/metamodelica.tmGrammar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ patterns:
name: storage.type

## Polymorphic types
- begin: \b(list|tuple|array|Option)\s*<
- begin: \b(list|tuple|array|Option)<
end: '>'
beginCaptures:
1:
name: storage.type
patterns:
- include: '#polymorphic_type'

- begin: \b(\w+)\s*<
- begin: \b(\w+)<
end : '>'
beginCaptures:
1:
Expand Down Expand Up @@ -171,7 +171,7 @@ repository:
- include: '#polymorphic_type'
- match: \b(Real|Integer|Boolean|String|enumeration|type)\b
name: storage.type
- match: \b([\w\.]+)\b
- match: \b(\w+)\b
name: entity.name.type

scopeName: source.metamodelica
3 changes: 2 additions & 1 deletion test/metamodelica/FunctionDoc.test.mo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public function foo
output Option<SimCode.Awesome> awesome;
//^^^^^^ source.metamodelica keyword.control
// ^^^^^^ source.metamodelica storage.type
// ^^^^^^^^^^^^^^^ source.metamodelica entity.name.type
// ^^^^^^^ source.metamodelica entity.name.type
// ^^^^^^^ source.metamodelica entity.name.type
// [...]
end foo;

Expand Down
5 changes: 5 additions & 0 deletions test/metamodelica/Types.test.mo
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ type TL = UnorderedMap<Key, Value>;
// ^^^^^^^^^^^^ source.metamodelica entity.name.type
// ^^^ source.metamodelica entity.name.type
// ^^^^^ source.metamodelica entity.name.type

x < 1 and x > 0;
//^ keyword.operator.comparison
// ^^^ keyword.control
// ^ keyword.operator.comparison

0 comments on commit c75da5e

Please sign in to comment.