Skip to content

Commit

Permalink
chore: add section + tests for literals in PARI/GP
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-semenov committed Apr 21, 2024
1 parent d261f9d commit 43e0e48
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/literals.YAML-tmLanguage
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
repository:
literals:
patterns:
- include: "#numeric"

repository:
numeric:
patterns:
-
match: '\b(0(x|X)[0-9A-Fa-f]*)\b'
name: constant.numeric.hex
-
match: '\b(0(b|B)[0-1]*)\b'
name: constant.numeric.bin
-
match: '\b([0-9]*\.[0-9]*\s*[eE][+-]?[0-9]+)\b'
name: constant.numeric.float
-
match: '\b([0-9]+)\b'
name: constant.numeric.int
1 change: 1 addition & 0 deletions src/main.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repository:
patterns:
- include: "#comments"
- include: "#functions"
- include: "#literals"
scopeName: source.parigp
$schema: >-
https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json
17 changes: 17 additions & 0 deletions tests/Literals.test.gp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## SYNTAX TEST "source.parigp" "Literals"

1.23E-10
##^^^^^^^^ source.parigp constant.numeric.float

-123 + 043664.32
## ^^^ source.parigp constant.numeric.int
##. ^^^^^^^^^ source.parigp constant.numeric.float

00432
##^^^^^ source.parigp constant.numeric.int

0x12A3F
##^^^^^^^ source.parigp constant.numeric.hex

0b00011001
##^^^^^^^^^^ source.parigp constant.numeric.bin

0 comments on commit 43e0e48

Please sign in to comment.