Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoqiangwang committed Aug 22, 2024
0 parents commit 6e2c4b8
Show file tree
Hide file tree
Showing 11 changed files with 344 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set default behavior to automatically normalize line endings.
* text=auto
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build/release vsix package

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install dependencies
run: |
npm install -g @vscode/vsce
- name: Build package
run: vsce package
- name: Release
if: startsWith(github.ref, 'refs/tags')
run: |
awk -v ver=${{ github.ref_name }} '/^## Version / { if (p) { exit }; if ($3 == ver) { p=1; next } } p && NF' CHANGELOG.md > RELEASE_NOTES
gh release create ${{ github.ref_name }} -F RELEASE_NOTES *.vsix
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.vsix
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}
4 changes: 4 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode/**
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log

## Version 0.0.1 - 2024-08-22

- Initial release
8 changes: 8 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2024 Xiaoqiang Wang

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# vscode-ecmcPLC

Syntax highlighting for ecmc PLC files.
35 changes: 35 additions & 0 deletions language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"comments": {
// symbol used for single line comment.
"lineComment": "#"
},
// symbols used as brackets
"brackets": [
["{", "}"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["'", "'"]
],
// symbols that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["(", ")"],
["'", "'"]
],
"onEnterRules": [
{
// Decrease indentation after single line if/else if/else, for, or while
"previousLineText": "^\\s*(((else ?)?if|for|while)\\s*\\(.*\\)\\s*|else\\s*)$",
// But make sure line doesn't have braces or is not another if statement
"beforeText": "^\\s+([^{i\\s]|i(?!f\\b))",
"action": {
"indent": "outdent"
}
}
]
}
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "vscode-ecmcPLC",
"displayName": "vscode-ecmcPLC",
"description": "ECMC PLC syntax highlight",
"version": "0.0.1",
"engines": {
"vscode": "*"
},
"categories": [
"Programming Languages"
],
"publisher": "PSI",
"repository": {
"url": "https://github.com/paulscherrerinstitue/vscode-ecmcPLC"
},
"contributes": {
"languages": [{
"id": "ecmcPLC",
"aliases": ["ecmcPLC"],
"extensions": [".plc"],
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "ecmcPLC",
"scopeName": "source.ecmcPLC",
"path": "./syntaxes/ecmcPLC.tmLanguage.json"
}]
}
}
213 changes: 213 additions & 0 deletions syntaxes/ecmcPLC.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "ecmcPLC",
"scopeName": "source.ecmcPLC",
"patterns": [
{
"include": "#comments"
},
{
"include": "#keywords"
},
{
"include": "#operators"
},
{
"include": "#functions"
},
{
"include": "#numbers"
},
{
"include": "#variables"
},
{
"include": "#strings"
},
{
"include": "#macros"
},
{
"include": "#blocks"
}
],
"repository": {
"keywords": {
"patterns": [
{
"name": "keyword.operator.logical.ecmcPLC",
"match": "\\b(and|mand|mor|nand|nor|not|or|shl|shr|xnor|xor|true|false)\\b"
},
{
"name": "keyword.control",
"match": "\\b(for|while|if|else|return|switch|case|repeat|until|break|continue)\\b"
},
{
"name": "storage.type.ecmcPLC",
"match": "\\b(var)\\b"
}
]
},
"operators": {
"patterns": [
{
"match": "\\+=|-=|\\*=|(?<!\\()/=",
"name": "keyword.operator.assignment.compound.ecmcPLC"
},
{
"match": "<>|!=|<=|>=|==|<|>",
"name": "keyword.operator.comparison.ecmcPLC"
},
{
"match": "%=|\\+=|-=|\\*=|(?<!\\()/=",
"name": "keyword.operator.assignment.compound.ecmcPLC"
},
{
"match": ":=",
"name": "keyword.operator.assignment.ecmcPLC"
},
{
"match": "\\+|-|\\*|/|%|\\^",
"name": "keyword.operator.ecmcPLC"
}
]
},
"functions": {
"patterns": [
{
"name": "support.function.math.ecmcPLC",
"match": "\\b(abs|avg|ceil|clamp|dot|equal|erf|erfc|exp|expm1|floor|frac|log|log10|log1p|log2|logn|max|min|mul|ncdf|not_equal|root|round|roundn|sgn|sqrt|sum|swap|trunc|println)\\b"
},
{
"name": "support.function.trigometry.ecmcPLC",
"match": "\\b(acos|acosh|asin|asinh|atan|atanh|atan2|cos|cosh|cot|csc|sec|sin|sinc|sinh|tan|tanh|hypot|rad2deg|deg2grad|deg2rad|grad2deg)\\b"
},
{
"name": "support.function.ecmc.ecmcPLC",
"match": "\\bmc[0-9a-zA-Z_]+\\b"
}
]
},
"variables": {
"name": "variable.other.ecmcPLC",
"patterns": [
{
"include": "#macros"
},
{
"include": "#macro_ref"
}
]
},
"numbers": {
"patterns": [
{
"match": "(?<![\\w\\d.])0[xX][0-9A-Fa-f]+(\\.[0-9A-Fa-f]*)?([eE]-?\\d*)?([pP][-+]\\d+)?",
"name": "constant.numeric.float.hexadecimal.ecmcPLC"
},
{
"match": "(?<![\\w\\d.])0[xX]\\.[0-9A-Fa-f]+([eE]-?\\d*)?([pP][-+]\\d+)?",
"name": "constant.numeric.float.hexadecimal.ecmcPLC"
},
{
"match": "(?<![\\w\\d.])0[xX][0-9A-Fa-f]+(?![pPeE.0-9])",
"name": "constant.numeric.integer.hexadecimal.ecmcPLC"
},
{
"match": "(?<![\\w\\d.])\\d+(\\.\\d*)?([eE]-?\\d*)?",
"name": "constant.numeric.float.ecmcPLC"
},
{
"match": "(?<![\\w\\d.])\\.\\d+([eE]-?\\d*)?",
"name": "constant.numeric.float.ecmcPLC"
},
{
"match": "(?<![\\w\\d.])\\d+(?![pPeE.0-9])",
"name": "constant.numeric.integer.ecmcPLC"
}
]
},
"comments": {
"name": "comment.line.number-sign.ecmcPLC",
"begin": "#",
"end": "$",
"patterns": [
{
"name": "constant.character.escape.ecmcPLC",
"match": "\\\\."
}
]
},
"strings": {
"patterns": [
{
"begin": "'",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.ecmcPLC"
}
},
"end": "'[ \\t]*|(?=\\n)",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.ecmcPLC"
}
},
"name": "string.quoted.single.ecmcPLC",
"patterns": [
{
"include": "#escaped_char"
}
]
}
]
},
"macros": {
"patterns": [
{
"name": "variable.parameter.epics.ecmcPLC",
"begin": "\\$\\{",
"end": "\\}",
"patterns": [ { "include": "#macro_ref" } ]
},
{
"name": "variable.parameter.epics.ecmcPLC",
"begin": "\\$\\(",
"end": "\\)",
"patterns": [ { "include": "#macro_ref" } ]
}
]
},
"macro_ref": {
"patterns": [
{
"name": "variable.parameter.epics.ecmcPLC",
"match": "[A-Z+a-z+0-9+_]+"
}
]
},
"blocks": {
"name": "meta.block.ecmcPLC",
"begin": "\\{",
"end": "\\}",
"patterns": [
{
"include": "$self"
}
]
},
"escaped_char": {
"patterns": [
{
"name": "constant.character.escape.ecmcPLC",
"match": "\\\\[nrtbvf]"
},
{
"name": "constant.character.escape.byte.ecmcPLC",
"match": "\\\\0x[0-9A-Fa-f]{2}"
}

]
}
}
}

0 comments on commit 6e2c4b8

Please sign in to comment.