Skip to content

Commit 4c84ad2

Browse files
committed
functions: rnd, atn and sqr added
1 parent d45ab10 commit 4c84ad2

File tree

4 files changed

+65
-5
lines changed

4 files changed

+65
-5
lines changed

server/src/macroLanguageService/languageFacts/builtinData.ts

+28-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export const functionSignatures: { [name: string]: FunctionSignature[] } = {
135135
param: [ { _bracket: '[' }, { _param: [ { value1: 'value1'} ] }, { _bracket: ']' }, { _escape: '/' }, { _bracket: '[' }, { _param: [ { value2: 'value2'} ] }, { _bracket: ']' } ]
136136
},
137137
{
138-
description: 'Arc tangent (one parameter), ATN can also be used.',
138+
description: 'Arc tangent (one parameter), ATN can also be used',
139139
param: [ { _bracket: '[' }, { _param: [ { value: 'value'} ] }, { _bracket: ']' } ]
140140
},
141141
{
@@ -144,12 +144,33 @@ export const functionSignatures: { [name: string]: FunctionSignature[] } = {
144144
param: [ { _bracket: '[' }, { _param: [ { value1: 'value1' } , { value2: 'value2'} ] }, { _bracket: ']' } ]
145145
}
146146
],
147+
'atn': [
148+
{
149+
description: 'Arc tangent (two parameters)',
150+
param: [ { _bracket: '[' }, { _param: [ { value1: 'value1'} ] }, { _bracket: ']' }, { _escape: '/' }, { _bracket: '[' }, { _param: [ { value2: 'value2'} ] }, { _bracket: ']' } ]
151+
},
152+
{
153+
description: 'Arc tangent (one parameter)',
154+
param: [ { _bracket: '[' }, { _param: [ { value: 'value'} ] }, { _bracket: ']' } ]
155+
},
156+
{
157+
description: 'Arc tangent (two parameters)',
158+
delimiter: ',',
159+
param: [ { _bracket: '[' }, { _param: [ { value1: 'value1' } , { value2: 'value2'} ] }, { _bracket: ']' } ]
160+
}
161+
],
147162
'sqrt': [
148163
{
149164
description: 'Square root, SQR can also be used',
150165
param: [ { _bracket: '[' }, { _param: [ { value: 'value' } ] }, { _bracket: ']' } ]
151166
}
152167
],
168+
'sqr': [
169+
{
170+
description: 'Square root',
171+
param: [ { _bracket: '[' }, { _param: [ { value: 'value' } ] }, { _bracket: ']' } ]
172+
}
173+
],
153174
'abs': [
154175
{
155176
description: 'Absolute value',
@@ -174,6 +195,12 @@ export const functionSignatures: { [name: string]: FunctionSignature[] } = {
174195
param: [ { _bracket: '[' }, { _param: [ { value: 'value' } ] }, { _bracket: ']' } ]
175196
}
176197
],
198+
'rnd': [
199+
{
200+
description: 'Rounding off',
201+
param: [ { _bracket: '[' }, { _param: [ { value: 'value' } ] }, { _bracket: ']' } ]
202+
}
203+
],
177204
'fix': [
178205
{
179206
description: 'Rounding down to an integer',

server/src/macroLanguageService/parser/macroScanner.ts

+3
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,14 @@ staticFunctionTable['tan'] = TokenType.Ffunc;
217217
staticFunctionTable['asin'] = TokenType.Ffunc;
218218
staticFunctionTable['acos'] = TokenType.Ffunc;
219219
staticFunctionTable['atan'] = TokenType.Ffunc;
220+
staticFunctionTable['atn'] = TokenType.Ffunc;
220221
staticFunctionTable['sqrt'] = TokenType.Ffunc;
222+
staticFunctionTable['sqr'] = TokenType.Ffunc;
221223
staticFunctionTable['abs'] = TokenType.Ffunc;
222224
staticFunctionTable['bin'] = TokenType.Ffunc;
223225
staticFunctionTable['bcd'] = TokenType.Ffunc;
224226
staticFunctionTable['round'] = TokenType.Ffunc;
227+
staticFunctionTable['rnd'] = TokenType.Ffunc;
225228
staticFunctionTable['fix'] = TokenType.Ffunc;
226229
staticFunctionTable['fup'] = TokenType.Ffunc;
227230
staticFunctionTable['ln'] = TokenType.Ffunc;

snippets/snippets.json

+33-3
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,37 @@
152152
"atan": {
153153
"prefix": "atan",
154154
"body": "ATAN[${1:value}]",
155-
"description": "Arc tangent (one parameter), ATN can also be used.",
155+
"description": "Arc tangent (one parameter), ATN can also be used",
156156
"scope": "source.macro"
157157
},
158158
"atan2": {
159159
"prefix": "atan",
160160
"body": "ATAN[${1:value1}]/[${2:value2}]",
161-
"description": "Arc tangent (two parameters), ATN can also be used.",
161+
"description": "Arc tangent (two parameters), ATN can also be used",
162162
"scope": "source.macro"
163163
},
164164
"atan3": {
165165
"prefix": "atan",
166166
"body": "ATAN[${1:name1},${2:name2}]",
167-
"description": "Arc tangent (two parameters), ATN can also be used.",
167+
"description": "Arc tangent (two parameters), ATN can also be used",
168+
"scope": "source.macro"
169+
},
170+
"atn": {
171+
"prefix": "atn",
172+
"body": "ATN[${1:value}]",
173+
"description": "Arc tangent (one parameter)",
174+
"scope": "source.macro"
175+
},
176+
"atn2": {
177+
"prefix": "atn",
178+
"body": "ATN[${1:value1}]/[${2:value2}]",
179+
"description": "Arc tangent (two parameters)",
180+
"scope": "source.macro"
181+
},
182+
"atn3": {
183+
"prefix": "atn",
184+
"body": "ATN[${1:name1},${2:name2}]",
185+
"description": "Arc tangent (two parameters)",
168186
"scope": "source.macro"
169187
},
170188
"sqrt": {
@@ -173,6 +191,12 @@
173191
"description": "Square root, SQR can also be used.",
174192
"scope": "source.macro"
175193
},
194+
"sqr": {
195+
"prefix": "sqr",
196+
"body": "SQR[${1:value}]",
197+
"description": "Square root",
198+
"scope": "source.macro"
199+
},
176200
"abs": {
177201
"prefix": "abs",
178202
"body": "ABS[${1:value}]",
@@ -197,6 +221,12 @@
197221
"description": "Rounding off, RND can also be used",
198222
"scope": "source.macro"
199223
},
224+
"rnd": {
225+
"prefix": "rnd",
226+
"body": "RND[${1:value}]",
227+
"description": "Rounding off",
228+
"scope": "source.macro"
229+
},
200230
"fix": {
201231
"prefix": "fix",
202232
"body": "FIX[${1:value}]",

syntaxes/macro.tmLanguage.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
},
198198
"functions_math" : {
199199
"name":"support.function.math.macro",
200-
"match":"(?i)(?<=^|\\W|\\d)(SIN|COS|TAN|ASIN|ACOS|ATAN|SQRT|ABS|BIN|BCD|ROUND|FIX|FUP|LN|EXP|POW|ADP|PRM)(?=\\s*\\[)"
200+
"match":"(?i)(?<=^|\\W|\\d)(SIN|COS|TAN|ASIN|ACOS|ATAN|ATN|SQRT|SQR|ABS|BIN|BCD|ROUND|RND|FIX|FUP|LN|EXP|POW|ADP|PRM)(?=\\s*\\[)"
201201
},
202202
"functions_command" : {
203203
"name":"support.function.macro",

0 commit comments

Comments
 (0)