Skip to content

Commit de6eb9e

Browse files
committed
Slightly modify snippets and token detection
1 parent 214c860 commit de6eb9e

File tree

5 files changed

+52
-30
lines changed

5 files changed

+52
-30
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
All notable changes to the "ti-basic" extension will be documented in this file.
44

5+
## [0.2.6] - 2024-01-06
6+
7+
### Added
8+
9+
- Add support for matricies [A] through [J]
10+
11+
### Changed
12+
13+
- Less strict error checking for tokens to correctly highlight more often, mentioned in [#3](https://github.com/TIny-Hacker/language-ti-basic/issues/3)
14+
- Check for ` ` and `(` to ensure correct syntax for certain tokens
15+
- Change logical operation scope to `keyword.operator.expression`, suggested by [nineteendo](https://github.com/nineteendo)
16+
- Handle snippet arguments slightly differently to consistently highlight them
17+
518
## [0.2.1] - 2023-12-11
619

720
### Fixed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ti-basic",
33
"displayName": "TI-BASIC",
4-
"version": "0.2.1",
4+
"version": "0.2.6",
55
"description": "Syntax highlighting for z80 TI-BASIC",
66
"author": {
77
"name": "TIny_Hacker",

snippets/tibasic.code-snippets

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"scope": "ti-basic",
44
"prefix": ["for", "For"],
55
"body": [
6-
"For(${1:variable},${2:start},${3:end},${4:step})",
6+
"For(${1:<variable>},${2:<start>},${3:<end>},${4:<step>})",
77
"$0",
88
"End"
99
],
@@ -13,7 +13,7 @@
1313
"if": {
1414
"scope": "ti-basic",
1515
"prefix": ["if", "If"],
16-
"body": ["If ${1:condition}",
16+
"body": ["If ${1:<condition>}",
1717
"Then",
1818
"$0",
1919
"End"
@@ -24,7 +24,7 @@
2424
"if-else": {
2525
"scope": "ti-basic",
2626
"prefix": ["ife", "IfE"],
27-
"body": ["If ${1:condition}",
27+
"body": ["If ${1:<condition>}",
2828
"Then",
2929
"${2:statements}",
3030
"Else",
@@ -37,7 +37,7 @@
3737
"while": {
3838
"scope": "ti-basic",
3939
"prefix": ["while", "While"],
40-
"body": ["While ${1: condition}",
40+
"body": ["While ${1:<condition>}",
4141
"$0",
4242
"End"
4343
]
@@ -46,11 +46,9 @@
4646
"repeat":{
4747
"scope": "ti-basic",
4848
"prefix": ["repeat", "Repeat"],
49-
"body": ["Repeat ${1: condition}",
49+
"body": ["Repeat ${1:<condition>}",
5050
"$0",
5151
"End"
5252
]
5353
}
54-
55-
56-
}
54+
}

syntaxes/ti-basic.tmLanguage.json

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
33
"name": "8xp",
44
"patterns": [
5+
{
6+
"include": "#snippets"
7+
},
58
{
69
"include": "#control"
710
},
@@ -28,11 +31,15 @@
2831
}
2932
],
3033
"repository": {
34+
"snippets": {
35+
"name": "variable.other.8xp",
36+
"match": "<[a-z ]+>"
37+
},
3138
"control": {
3239
"patterns": [
3340
{
3441
"name": "keyword.control.8xp",
35-
"match": "\\b(If|Then|Else|For|While|Repeat|End|Pause|Lbl|Goto|Wait|IS>|DS<|Menu|Return|Stop|GraphStyle|GraphColor|OpenLib|ExecLib\\b)"
42+
"match": "(If |Then|Else|For(?=\\()|While |Repeat |End|Pause|Lbl |Goto |Wait |IS>(?=\\()|DS<(?=\\()|Menu(?=\\()|Return|Stop|GraphStyle(?=\\()|GraphColor(?=\\()|OpenLib(?=\\()|ExecLib )"
3643
},
3744
{
3845
"name": "keyword.control.8xp",
@@ -48,7 +55,7 @@
4855
},
4956
{
5057
"name": "keyword.operator.expression.8xp",
51-
"match": "\\b(and|or|not|xor)\\b"
58+
"match": "( (and|or|xor) |not(?=\\())"
5259
}
5360
]
5461
},
@@ -60,19 +67,19 @@
6067
"patterns": [
6168
{
6269
"name": "entity.name.function.8xp",
63-
"match": "\\bprgm[A-Zθ][0-9A-Zθ]{0,7}\\b"
70+
"match": "prgm[A-Zθ][0-9A-Zθ]{0,7}"
6471
},
6572
{
6673
"name": "entity.name.function.8xp",
67-
"match": "(?<=[^a-z]|Ans|^)(abs|angle|ANOVA|augment|bal|binom[cp]df|checkTmr|X²([cp]df|\\-Test|GOF\\-Test)|conj|cos(h|)(⁻¹|)|cumSum|dayOfWk|dbd|▶Dec|det|dim|▶DMS|e\\^|\\|E|▶Eff|eval|expr|F[cp]df|▶F◀▶D|Fill|Fix|Float|fMax|fMin|fnInt|[fi]Part|▶Frac|gcd|geomet[cp]df|get(Date|Time)|get(Dt|Tm)(Fmt|Str)|getKey|G\\-T|\\|i|identity|imag|inString|int|ΣInt|inv(Binom|Norm|T)|irr|isClockOn|lcm|length|∆List|ln|log(BASE|)|max|mean|median|Med-Med|min|n[CP]r|n\\/d|nDeriv|▶n/d◀▶Un/d|▶Nom|normal[cp]df|npv|piecewise|poisson[cp]df|▶Polar|ΣPrn|prod|[12]\\-PropZ(Int|Test)|pxl\\-Test|P▶Rx|P▶Ry|rand|randBin|randInt|randIntNoRep|randM|randNorm|re\\^θi|real|▶Rect|ref|remainder|round|\\*row|row\\+|\\*row\\+|rowSwap|rref|R▶P[rθ]|seq|setDate|setDtFmt|setTime|setTmFmt|sin|sin⁻¹|sinh|sinh⁻¹|solve|startTmr|stdDev|su[bm]|Σ|tan|tan⁻¹|tanh|tanh⁻¹|t[cp]df|timeCnv|toString|tvm_FV|tvm_I%|tvm_N|tvm_Pmt|tv_PV|uvAxes|uwAxes|variance|vwAxes|xyLine)\\b"
74+
"match": "(abs|angle|ANOVA|augment|bal|binom[cp]df|checkTmr|X²([cp]df|\\-Test|GOF\\-Test)|conj|cos(h|)(⁻¹|)|cumSum|dayOfWk|dbd|▶Dec|det|dim|▶DMS|e\\^|\\|E|▶Eff|eval|expr|F[cp]df|▶F◀▶D|Fill|Fix|Float|fMax|fMin|fnInt|[fi]Part|▶Frac|gcd|geomet[cp]df|get(Date|Time)|get(Dt|Tm)(Fmt|Str)|getKey|G\\-T|\\|i|identity|imag|inString|int|ΣInt|inv(Binom|Norm|T)|irr|isClockOn|lcm|length|∆List|ln|log(BASE|)|max|mean|median|Med-Med|min|n[CP]r|n\\/d|nDeriv|▶n/d◀▶Un/d|▶Nom|normal[cp]df|npv|piecewise|poisson[cp]df|▶Polar|ΣPrn|prod|[12]\\-PropZ(Int|Test)|pxl\\-Test|P▶Rx|P▶Ry|rand|randBin|randInt|randIntNoRep|randM|randNorm|re\\^θi|real|▶Rect|ref|remainder|round|\\*row|row\\+|\\*row\\+|rowSwap|rref|R▶P[rθ]|seq|setDate|setDtFmt|setTime|setTmFmt|sin|sin⁻¹|sinh|sinh⁻¹|solve|startTmr|stdDev|su[bm]|Σ|tan|tan⁻¹|tanh|tanh⁻¹|t[cp]df|timeCnv|toString|tvm_FV|tvm_I%|tvm_N|tvm_Pmt|tv_PV|uvAxes|uwAxes|variance|vwAxes|xyLine)(?=\\()"
6875
},
6976
{
7077
"name": "entity.name.function.8xp",
71-
"match": "\\b(Archive|Asm|AsmComp|Asm84CEPrgm|AUTO|AxesOff|AxesOn|a\\+bi|BackgroundOff|BackgroundOn|BorderColor|Boxplot|Circle|CLASSIC|Clear Entries|ClockOff|ClockOn|ClrAllLists|ClrDraw|ClrHome|ClrList|ClrTableCoordOff|CoordOn|CubicReg|DEC|Degree|Depend(Ask|Auto)|DetectAsym(Off|On)|Diagnostic(Off|On)|Disp(Graph|Table|)|Dot\\-(Thick|Thin)|Draw(F|Inv)|Eng|Equ▶String|Exp(Reg|rOff|rOn)|Fn(Off|On)|Full|Func|GarbageCollect|Get|GetCalc|GridDot|GridLine|GridOffHoriz|Horizontal|HistogramIndpnt(Ask|Auto)|Input|Label(Off|On)|Line|(LinReg)(?=\\((a\\+bx|ax\\+b)\\))|((?<=LinReg)\\((a\\+bx|ax\\+b)\\))|LinRegT(Int|Test)|List▶matr|LnReg|Logistic|Manual\\-Fit|MATHPRINT|Matr▶list|ModBoxPlot|Normal|NormProbPlot|Output|Param|Plot[1-3]|Plots(Off|On)|Pmt_(Bgn|End)|Polar|PolarGC|Prompt|Pt\\-(Change|Off|On)|PwrReg|Pxl\\-(Change|Off|On)|(Quad|Quart)Reg|Radian|Real|Recall(GDB|Pic)|RectGC|2\\-SampFTest|2\\-Samp[TZ]Int|2\\-Samp[TZ]Test|Scatter|Sci|Select|Send|Seq|SEQ|Sequential|SetUpEditor|Shade|ShadeX²|ShadeF|ShadeNorm|Shade_t|Simul|SinReg|Sort[AD]|STATWIZARD (OFF|ON)|Store(GDB|Pic)|String▶Equ|Tangent|Text|TextColor|Thick|Thin|Time|TInterval|Trace|T\\-Test|UnArchive|Un\\/d|[12]\\-Var Stats|Vertical|Web|ZBox|ZDecimal|ZFrac1/[2-58]|ZFrac1/10|ZInteger|ZInterval|Zoom In|Zoom Out|ZoomFit|ZoomRcl|ZoomStat|ZoomSto|ZPrevious|ZQuadrant1|ZSquare|ZStandard|Z\\-Test|ZTrig)\\b"
78+
"match": "(Archive |Asm(?=\\()|AsmComp(?=\\()|Asm84CEPrgm|AUTO|AxesOff|AxesOn|a\\+bi|BackgroundOff|BackgroundOn|BorderColor|Boxplot|Circle(?=\\()|CLASSIC|Clear Entries|ClockOff|ClockOn|ClrAllLists|ClrDraw|ClrHome|ClrList|ClrTableCoordOff|CoordOn|CubicReg|DEC|Degree|Depend(Ask|Auto)|DetectAsym(Off|On)|Diagnostic(Off|On)|Disp(Graph|Table| )|Dot\\-(Thick|Thin)|Draw(F|Inv)|Eng|Equ▶String(?=\\()|Exp(Reg|rOff|rOn)|Fn(Off|On)|Full|Func|GarbageCollect|Get(Calc)?(?=\\()|GridDot|GridLine|GridOffHoriz|Horizontal |HistogramIndpnt(Ask|Auto)|Input |Label(Off|On)|Line(?=\\()|LinReg(?=\\((a\\+bx|ax\\+b)\\))|(?<=LinReg)\\((a\\+bx|ax\\+b)\\)|LinRegT(Int|Test)|List▶matr(?=\\()|LnReg|Logistic |Manual\\-Fit|MATHPRINT|Matr▶list|ModBoxPlot|Normal|NormProbPlot|Output(?=\\()|Param|Plot[1-3](?=\\()|Plots(Off|On)|Pmt_(Bgn|End)|(►)?Polar|PolarGC|Prompt |Pt\\-(Change|Off|On)(?=\\()|PwrReg |Pxl\\-(Change|Off|On)(?=\\()|(Quad|Quart)Reg |Radian|Real|Recall(GDB|Pic) |RectGC|2\\-SampFTest |2\\-SampT(Int|Test) |2\\-SampZ(Int|Test)(?=\\()|Scatter|Sci|Select(?=\\()|Send(?=\\()|Seq|SEQ\\(n(\\+[12])?\\)|Sequential|SetUpEditor |Shade(X²|F|Norm|_t)?(?=\\()|Simul|SinReg |Sort[AD](?=\\()|STATWIZARD (OFF|ON)|Store(GDB|Pic) |String▶Equ(?=\\()|Tangent(?=\\()|Text(?=\\()|TextColor(?=\\()|Thick|Thin|Time|TInterval |Trace|T\\-Test |UnArchive |Un\\/d|[12]\\-Var Stats |Vertical |Web|ZBox|ZDecimal|ZFrac1/[2-58]|ZFrac1/10|ZInteger|ZInterval|Zoom In|Zoom Out|ZoomFit|ZoomRcl|ZoomStat|ZoomSto|ZPrevious|ZQuadrant1|ZSquare|ZStandard|Z\\-Test(?=\\()|ZTrig)"
7279
},
7380
{
7481
"name": "entity.name.function.8xp",
75-
"match": "(?<=(Goto|Lbl) )[0-9A-Zθ]{1,2}\\b"
82+
"match": "(?<=(Goto|Lbl) )[0-9A-Zθ]{1,2}"
7683
}
7784
]
7885
},
@@ -89,59 +96,63 @@
8996
},
9097
{
9198
"name": "variable.parameter.8xp",
92-
"match": "\\b([A-Zθ]|Xmin|Xmax|Xscl|Ymin|Ymax|YScl|Xres|ΔX|ΔY|XFact|YFact|TraceStep|Tmin|Tmax|Tstep|θmin|θmax|θstep|[uvw]|((?<=[uvw])\\((nMin\\)))|nMin|nMax|PlotStart|PlotStep)\\b"
99+
"match": "([A-Zθ]|Xmin|Xmax|Xscl|Ymin|Ymax|YScl|Xres|ΔX|ΔY|XFact|YFact|TraceStep|Tmin|Tmax|Tstep|θmin|θmax|θstep|[uvw]|((?<=[uvw])\\((nMin\\)))|nMin|nMax|PlotStart|PlotStep)"
100+
},
101+
{
102+
"name": "variable.parameter.8xp",
103+
"match": "(ZXmin|ZXmax|ZXscl|ZYmin|ZYmax|ZYscl|ZXres|ZTmin|ZTmax|ZTstep|Zθmin|Zθmax|Zθstep|Z[uvw]|((?<=Z[uvw])\\((nMin\\)))|ZnMin|ZnMax|ZPlotStart|ZPlotStep)"
93104
},
94105
{
95106
"name": "variable.parameter.8xp",
96-
"match": "\\b(ZXmin|ZXmax|ZXscl|ZYmin|ZYmax|ZYscl|ZXres|ZTmin|ZTmax|ZTstep|Zθmin|Zθmax|Zθstep|Z[uvw]|((?<=Z[uvw])\\((nMin\\)))|ZnMin|ZnMax|ZPlotStart|ZPlotStep)\\b"
107+
"match": "GDB[0-9]"
97108
},
98109
{
99110
"name": "variable.parameter.8xp",
100-
"match": "\\bGDB[0-9]\\b"
111+
"match": "(Pic[0-9]|Image[0-9])"
101112
},
102113
{
103114
"name": "variable.parameter.8xp",
104-
"match": "\\b(Pic[0-9]|Image[0-9])\\b"
115+
"match": "(n|x̄|Sx|σx|ȳ|Sy|σy|minX|maxX|minY|maxY|Σx|Σx²|Σy|Σy²|Σxy|RegEQ|[a-e]|r|r²|R²|p|z|t|x²|\\|F|df|ṗ|ṗ1|ṗ2|s|x̄1|x̄2|Sx1|Sx2|Sxp|n1|n2|lower|upper|x1|y1|x2|y2|x3|y3|Q1|Med|Q3)"
105116
},
106117
{
107118
"name": "variable.parameter.8xp",
108-
"match": "\\b(n|x̄|Sx|σx|ȳ|Sy|σy|minX|maxX|minY|maxY|Σx|Σx²|Σy|Σy²|Σxy|RegEQ|[a-e]|r|r²|R²|p|z|t|x²|\\|F|df|ṗ|ṗ1|ṗ2|s|x̄1|x̄2|Sx1|Sx2|Sxp|n1|n2|lower|upper|x1|y1|x2|y2|x3|y3|Q1|Med|Q3)\\b"
119+
"match": "(Tbl(Start|Input)|∆Tbl)"
109120
},
110121
{
111122
"name": "variable.parameter.8xp",
112-
"match": "\\b(TblStart|∆Tbl|TblInput)\\b"
123+
"match": "Str[0-9]"
113124
},
114125
{
115126
"name": "variable.parameter.8xp",
116-
"match": "\\bStr[0-9]\\b"
127+
"match": "Y[0-9]"
117128
},
118129
{
119130
"name": "variable.parameter.8xp",
120-
"match": "\\bY[0-9]\\b"
131+
"match": "[XY][1-6]T"
121132
},
122133
{
123134
"name": "variable.parameter.8xp",
124-
"match": "\\b[XY][1-6]T\\b"
135+
"match": "r[1-6]"
125136
},
126137
{
127138
"name": "variable.parameter.8xp",
128-
"match": "\\br[1-6]\\b"
139+
"match": "\\|L[A-Zθ][0-9A-Zθ]{0,4}"
129140
},
130141
{
131142
"name": "variable.parameter.8xp",
132-
"match": "\\B\\|L[A-Zθ][0-9A-Zθ]{0,4}\\b"
143+
"match": "\\[[A-J]\\]"
133144
}
134145
]
135146
},
136147
"constants": {
137148
"patterns": [
138149
{
139150
"name": "constant.language.8xp",
140-
"match": "\\b(CENTER|LEFT|RIGHT)\\b"
151+
"match": "(CENTER|LEFT|RIGHT)"
141152
},
142153
{
143154
"name": "constant.language.8xp",
144-
"match": "\\b(BLUE|RED|BLACK|MAGENTA|GREEN|ORANGE|BROWN|NAVY|LTBLUE|YELLOW|WHITE|LTGRAY|MEDGRAY|GRAY|DARKGRAY)\\b"
155+
"match": "(BLUE|RED|BLACK|MAGENTA|GREEN|ORANGE|BROWN|NAVY|LTBLUE|YELLOW|WHITE|LTGRAY|MEDGRAY|GRAY|DARKGRAY)"
145156
}
146157
]
147158
},

0 commit comments

Comments
 (0)