From 266bd35dfbc15c642fbcd056f3c0495405ec4b62 Mon Sep 17 00:00:00 2001 From: lightumcc Date: Fri, 3 Nov 2023 12:09:47 +0800 Subject: [PATCH] add: snippets and clarify configuration --- package.json | 10 ++- snippets/cpc.json | 157 ---------------------------------------------- src/snippets.json | 85 +++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 159 deletions(-) delete mode 100644 snippets/cpc.json create mode 100644 src/snippets.json diff --git a/package.json b/package.json index fffbd67..00b18be 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "cpc-interpreter-extension", "displayName": "CAIE Pseudocode", "description": "A VSCode language support extension of CAIE PseudoCode", - "version": "0.0.5", + "version": "0.0.6", "publisher": "CreatechStudioShanghaiInc", "icon": "icon.png", "main": "./src/extension.ts", @@ -40,6 +40,12 @@ "path": "./syntaxes/cpc.tmLanguage.json" } ], + "snippets": [ + { + "language": "cpc", + "path": "./src/snippets.json" + } + ], "taskDefinitions": [ { "type": "cpc" @@ -88,7 +94,7 @@ "myCpcConfig.interpreterPath": { "type": "string", "default": "cpc", - "description": "Path to the CPC interpreter" + "description": "Path to the CPC interpreter, Please reboot VSCode after changing this setting." } } } diff --git a/snippets/cpc.json b/snippets/cpc.json deleted file mode 100644 index 62e7e37..0000000 --- a/snippets/cpc.json +++ /dev/null @@ -1,157 +0,0 @@ -{ - "variable declare" : { - "prefix" : [ - "DECLARE" - ], - "body" : [ - "DECLARE ${1:identifier} : ${2:type}" - ], - "description" : "VARIABLE DECLARE" - }, - "constant declare" : { - "prefix" : [ - "CONSTANT" - ], - "body" : [ - "CONSTANT ${1:identifier} = ${2:expression}" - ], - "description" : "CONSTANT DECLARE" - }, - "array declare" : { - "prefix" : [ - "DECLARE", - "ARRAY" - ], - "body" : [ - "DECLARE ${1:identifier} : ARRAY[${2:indexes}] OF ${3:type}" - ], - "description" : "ARRAY DECLARE" - }, - "for" : { - "prefix" : [ - "FOR" - ], - "body" : [ - "FOR ${1:identifier} <- ${2:start} TO ${3:end}", - "\t$0", - "NEXT $1" - ], - "description" : "FOR LOOP" - }, - "for step" : { - "prefix" : [ - "FOR", - "STEP" - ], - "body" : [ - "FOR ${1:identifier} <- ${2:start} TO ${3:end} TO ${4:step}", - "\t$0", - "NEXT $1" - ], - "description" : "FOR STEP LOOP" - }, - "while" : { - "prefix" : [ - "WHILE" - ], - "body" : [ - "WHILE ${1:condition} DO", - "\t$0", - "ENDWHILE" - ], - "description" : "WHILE LOOP" - }, - "repeat" : { - "prefix" : [ - "REPEAT" - ], - "body" : [ - "REPEAT", - "\t$0", - "UNTIL ${1:condition}" - ], - "description" : "REPEAT LOOP" - }, - "if" : { - "prefix" : [ - "IF" - ], - "body" : [ - "IF ${2:condition} THEN", - "\t$1", - "ELSE", - "\t$0", - "ENDIF" - ], - "description" : "IF CONDITION" - }, - "case" : { - "prefix" : [ - "CASE" - ], - "body" : [ - "CASE OF ${1:identifier}", - "\t$0", - "ENDCASE" - ], - "description" : "CASE CONDITION" - }, - "case item" : { - "prefix" : [ - "CASE ITEM" - ], - "body" : [ - "${1:identifier} : $0 ;" - ], - "description" : "A CASE ITEM" - }, - "procedure declare" : { - "prefix" : [ - "PROCEDURE" - ], - "body" : [ - "PROCEDURE ${1:identifier}(${2:parameters})", - "\t$0", - "ENDPROCEDURE" - ], - "description" : "PROCEDURE DECLARE" - }, - "function declare" : { - "prefix" : [ - "FUNCTION" - ], - "body" : [ - "FUNCTION ${1:identifier}(${2:parameters}) RETURNS ${3:type}", - "\t$0", - "ENDFUNCTION" - ], - "description" : "FUNCTION DECLARE" - }, - "call procedure" : { - "prefix" : [ - "CALL" - ], - "body" : [ - "CALL ${1:identifier}(${2:parameters})" - ], - "description" : "CALL PROCEDURE" - }, - "input" : { - "prefix" : [ - "INPUT" - ], - "body" : [ - "INPUT ${1:identifier}" - ], - "description" : "INPUT STATEMENT" - }, - "output" : { - "prefix" : [ - "OUTPUT" - ], - "body" : [ - "OUTPUT ${1: value}" - ], - "description" : "OUTPUT STATEMENT" - } -} \ No newline at end of file diff --git a/src/snippets.json b/src/snippets.json new file mode 100644 index 0000000..09cd7d6 --- /dev/null +++ b/src/snippets.json @@ -0,0 +1,85 @@ +{ + "For Loop": { + "prefix": [ + "FOR" + ], + "body": [ + "FOR ${3:element} <- ${1:start} TO ${2:end}", + "\t$0", + "NEXT $3" + ], + "description": "A for loop." + }, + "If": { + "prefix": [ + "IF" + ], + "body": [ + "IF ${1:condition} THEN", + "\t$0", + "ENDIF" + ], + "description": "An if statement" + }, + "For Loop With Step": { + "prefix": [ + "FORSTEP" + ], + "body": [ + "FOR ${4:element} <- ${1:start} TO ${2:end} STEP ${3:step}", + "\t$0", + "NEXT $4" + ], + "description": "A for loop with step." + }, + "While": { + "prefix": [ + "WHILE" + ], + "body": [ + "WHILE ${1:condition} DO", + "\t$0", + "ENDWHILE" + ], + "description": "A while loop." + }, + "Repeat": { + "prefix": [ + "REPEAT" + ], + "body": [ + "REPEAT", + "\t$0", + "UNTIL ${1:condition}" + ], + "description": "A repeat-until loop." + }, + "Declare": { + "prefix": [ + "DECLARE" + ], + "body": [ + "DECLARE ${1:identifier} : ${2:type}" + ], + "description": "Declare a variable." + }, + "Declare Array": { + "prefix": [ + "DECLAREARRAY" + ], + "body": [ + "DECLARE ${1:identifier} : ARRAY[${3:dimensions}] OF ${2:type}" + ], + "description": "Declare an array." + }, + "Declare Set": { + "prefix": [ + "DECLARESET" + ], + "body": [ + "DECLARE ${1:identifier} : SET OF ${2:type}" + ], + "description": "Declare an set." + } + +} \ No newline at end of file