I made a vs code syntax for calcscript but I cannot seem to get the hightlighting or the autocompetion working for my code.
This is my package.json:
{
"name": "calcscript-syntax-extension",
"displayName": "Calcscript Syntax",
"description": "Syntax highlighting and autocomplete for Calcscript",
"version": "1.0.2",
"publisher": "TheSadDays",
"engines": {
"vscode": "^1.0.0"
},
"categories": [
"Programming Languages"
],
"contributes": {
"languages": [
{
"id": "calcscript",
"aliases": [
"Calcscript"
],
"extensions": [
".calcscript"
]
}
],
"grammars": [
{
"language": "calcscript",
"scopeName": "source.calcscript",
"path": "syntaxes/calcscript.tmLanguage.json"
}
]
},
"icon": "icon.png",
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/install",
"test": "echo "Error: no test specified" && exit 1"
},
"devDependencies": {
"@types/vscode": "^1.0.0",
"vscode": "^1.0.0"
},
"keywords": [
"calcscript",
"syntax",
"highlighting"
],
"repository": {
"type": "git",
"url": "https://github.com/yourusername/calcscript-syntax-extension.git"
}
}
this is my tmLanguage:
{
"scopeName": "source.calcscript",
"patterns": [
{
"name": "comment.line.calcscript",
"begin": "'",
"end": "$"
},
{
"match": "\b(AND|OR|NOT|<|>|<=|>=|<>|+|-|\*|\^|&)\b",
"name": "keyword.operator.calcscript"
},
{
"begin": """,
"end": """,
"name": "string.double-quote.calcscript"
},
{
"begin": "'",
"end": "'",
"name": "string.single-quote.calcscript"
},
{
"match": "\b(Abs|Acos|Acosh|Asin|Asinh|Atan|Atanh|Ceiling|Cos|Cosh|Degrees|Even|Exp|Fact|Float|Floor|Int|Ln|Log|Log10|Max|Min|Mod|Odd|Pi|Radians|Rand|Round|Rounddown|Roundup|Sin|Sinh|Sqrt|Tan|Tanh|Trunc|Value)\b",
"name": "support.function.math.calcscript"
},
{
"match": "\b(Now|Weekday|Day|Month|Year|Hour|Minute|Second|ScheduledTime|ScheduledTimeUTC|TruncToHour|TruncToMinute|Weeknum)\b",
"name": "support.function.timestamp.calcscript"
},
{
"match": "\b(Char|Clean|Code|Find|Left|Lower|Mid|Initcap|Replace|Rept|Right|Substitute|Trim)\b",
"name": "support.function.character.calcscript"
},
{
"match": "\b(TagAddNewHistory|TagAverage|TagAverageArray|TagHistory|TagHistoryArray|TagMaximum|TagMaximumArray|TagMinimum|TagMinimumArray|TagModifyHistory|TagStatistics|TagStatisticsArray|TagSum|TagSumArray|TagUpdateHistory)\b",
"name": "support.function.history.calcscript"
},
{
"match": "\b(if|then|endif|else|elseif)\b",
"name": "keyword.control.calcscript"
},
{
"begin": "\b(if)\b",
"beginCapturingGroup": 1,
"end": "\b(endif|else)\b",
"name": "keyword.control.calcscript",
"patterns": [
{
"include": "#calcscript-block"
}
]
},
{
"begin": "\b(else)\b",
"end": "\b(endif)\b",
"name": "keyword.control.calcscript",
"patterns": [
{
"include": "#calcscript-block"
}
]
},
{
"repository": {
"calcscript-block": {
"begin": "\b(then)\b",
"end": "\b(endif)\b",
"name": "meta.block.calcscript",
"patterns": [
{
"include": "#calcscript-statements"
}
]
},
"calcscript-statements": {
"patterns": [
{
"include": "#calcscript-keywords"
},
{
"include": "#calcscript-variables"
}
]
},
"calcscript-keywords": {
"match": "\b(AND|OR|NOT|<|>|<=|>=|<>|+|-|\*|\^|&|SELECT|EXECUTE|FUNCTION|elseif|NOT)\b",
"name": "keyword.control.calcscript"
},
"calcscript-variables": {
"match": "\$[a-zA-Z]+",
"name": "variable.other.calcscript"
}
}
}
]
}
This is my first attempt at this so any help would be appreciated!
Code in question if you were wondering:
'================================================================================
' Variables
'================================================================================
Fill_Rate_Height_Instantaneous_Trigger = 0
High_Tank_Temperature = 0
High_Tank_Temperature_Warning = 0
Tank_Fill_Rate_Deviation = 0
Tank_Fill_Rate_Warning_30m = 0
Tank_Fill_Rate_Warning_40m = 0
Tank_High_Level = 0
Tank_Temp_Low = 0
min = .0007
'================================================================================
' Above Hurricane Level
' ( Event Triggering )
'================================================================================
if ( ( ( Level_1 + .1 ) > Hurricane_Heal ) OR ( ( Level_2 + .1 ) > Hurricane_Heal ) ) then
HC_Level_Good = 1
else
HC_Level_Good = 0
endif
'================================================================================
' Calculate Moving Level Limits
' ( Every 3 mins )
'================================================================================
'''''''''''''''''''' Add bad value condition ofr Level_1 ( What is a bad vaule? ) '''''''''''''''''''''
if ( ( Level_1 > 1 ) AND ( Level_1 < 99 ) AND ( ( TagAverage( Level_1, ( Now() - ( min * 66 ) ), ( Now() - ( min * 60 ) ), 50, 0 ) ) > 1 ) AND ( ( TagAverage( Level_1, ( Now() - ( min * 66 ) ), ( Now() - ( min * 60 ) ), 50, 0 ) ) < 99 ) ) then
Level_1_Moving_Limit = ( TagAverage( Level_1, ( Now() - ( min * 66 ) ), ( Now() - ( min * 60 ) ), 50, 0 ) ) + Max_Fill_Rate
else
Level_1_Moving_Limit = 110
endif
if ( ( Level_2 > 1 ) AND ( Level_2 < 99 ) AND ( ( TagAverage( Level_2, ( Now() - ( min * 66 ) ), ( Now() - ( min * 60 ) ), 50, 0 ) ) > 1 ) AND ( ( TagAverage( Level_2, ( Now() - ( min * 66 ) ), ( Now() - ( min * 60 ) ), 50, 0 ) ) < 99 ) ) then
Level_1_Moving_Limit = ( TagAverage( Level_2, ( Now() - ( min * 66 ) ), ( Now() - ( min * 60 ) ), 50, 0 ) ) + Max_Fill_Rate
else
Level_1_Moving_Limit = 110
endif
'================================================================================
' Event Triggers
'================================================================================
''''''''''''''''''''' Fill rate Hight Instantaneous Trigger ''''''''''''''''''''
if ( ( TagHistory( Level_1, Now(), 0 ) - TagHistory( Level_1, ( Now() - ( min * 60 ) ), 0 ) ) >= 0) then
Fill_Rate_Height_Instantaneous_Trigger = 1
endif
''''''''''''''''''''' Hight Tank Temperature Trigger ''''''''''''''''''''
if ( TagAverage( Temperature, Now(), ( Now() - 1 ), 0, 0 ) > Temperature_Max ) then
High_Tank_Temperature= 1
endif
''''''''''''''''''''' High Tank Temperature Warning Trigger ''''''''''''''''''''
if ( Temperature > ( Temperature_Max - 5 ) ) then
High_Tank_Temperature_Warning = 1
endif
''''''''''''''''''''' Tank Fill Rate Deviation Trigger ''''''''''''''''''''
if ( ( Level_Used_For_Compliance = Level_1 ) OR ( Level_Used_For_Compliance = Both_Levels ) ) then
if ( Moving_Limit < TagAverage( Level_1, ( Now() - ( min * 6 ) ), Now(), 50, 0 ) ) then
Tank_Fill_Rate_Deviation = 1
else
Tank_Fill_Rate_Deviation = 0
endif
else
Tank_Fill_Rate_Deviation = 0
endif
' Tank_Fill_Rate_Warning_30m = 1
' Tank_Fill_Rate_Warning_40m = 1
' Tank_High_Level = 1
' Tank_Temp_Low = 1
I tried researching but I could not find anything comprehensive about making vs code extensions, just to the point I am at now.