Skip to content

Commit

Permalink
chore: add operators section
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-semenov committed Apr 24, 2024
1 parent b436ff4 commit 0c9cf51
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repository:
- include: "#comments"
- include: "#functions"
- include: "#literals"
- include: "#operators"
scopeName: source.parigp
$schema: >-
https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json
39 changes: 39 additions & 0 deletions src/operators.YAML-tmLanguage
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
repository:
operators:
patterns:
-
match: '\b(!)'
captures:
1:
name: keyword.operator.factorial
-
match: '(&&|\|\||!\b)'
name: keyword.operator.logical
-
match: '(<=|>=|<|>)'
name: keyword.operator.comparison
-
match: '[^<>](=)'
name: keyword.operator.assignment
-
match: '(<<|>>)'
name: keyword.operator.shift
-
match: '(\-\-|\+\+)'
name: keyword.operator.increment-decrement
-
match: '(\-|\+|\*|\/|\\|\\/|%)'
name: keyword.operator.arithmetic
-
match: '(\+=|\-=|\*=|\/=|\\=|<<=|>>=)'
name: keyword.operator.arithmetic.assign
-
match: '(\.\.)'
name: keyword.operator.range
-
match: '(\~)'
name: keyword.operator.transpose
-
match: "[\\b\\)](\\')"
name: keyword.operator.derivative
36 changes: 36 additions & 0 deletions tests/Operators.test.gp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## SYNTAX TEST "source.parigp" "Operators"

(var! + 100!)
## ^ source.parigp keyword.operator.factorial
## ^ source.parigp keyword.operator.arithmetic
## ^ source.parigp keyword.operator.factorial

(1 && []) || (0 || "string")
## ^^ source.parigp keyword.operator.logical
## ^^ source.parigp keyword.operator.logical
## ^^ source.parigp keyword.operator.logical

if(!cond,,print("Bad!"));
## ^ source.parigp keyword.operator.logical

(1 >= 1) && (10 <= 11) || (x > 0)
## ^^ source.parigp keyword.operator.comparison
## ^^ source.parigp keyword.operator.logical
## ^^ source.parigp keyword.operator.comparison
## ^^ source.parigp keyword.operator.logical
## ^ source.parigp keyword.operator.comparison

y < 0
## ^ source.parigp keyword.operator.comparison

x = 10;
## ^ source.parigp keyword.operator.assignment

[1..100]
## ^^ source.parigp keyword.operator.range

[1, 2, 3; 4, 5, 6]~
## ^ source.parigp keyword.operator.transpose

('x^2 + 1)'
## ^ source.parigp keyword.operator.derivative

0 comments on commit 0c9cf51

Please sign in to comment.