Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaCrafter committed Feb 2, 2022
0 parents commit da44a32
Show file tree
Hide file tree
Showing 17 changed files with 324 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
out
dist
node_modules
.vscode-test/
*.vsix
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// A launch configuration that compiles the extension and then opens it 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": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
12 changes: 12 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.vscode/**
.vscode-test/**
out/test/**

src/**
.gitignore
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--ignore-engines true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Dmitriy Shiryaev

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.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# RnCore scripting language support

## Release Notes

### v0.1.0 — _03.02.2022_

Initial release. Basic syntax highlight.
Binary file added img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions img/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "rnscript-vscode",
"displayName": "RnScript",
"description": "RnCore scripting language support",
"icon": "img/logo.png",
"preview": true,
"publisher": "DimaCrafter",
"author": {
"name": "Dmitriy Shiryaev",
"email": "[email protected]"
},
"repository": "https://github.com/DePowered-LLC/rnscript-vscode.git",
"license": "MIT",
"version": "0.1.0",
"engines": {
"vscode": "^1.63.0"
},
"categories": [
"Programming Languages"
],
"activationEvents": [
"onLanguage:rnscript"
],
"main": "./out/extension.js",
"contributes": {
"languages": [
{
"id": "rnscript",
"aliases": ["RnScript", "rns"],
"extensions": [".rns"],
"configuration": "./syntaxes/rnscript.config.json"
}
],
"grammars": [
{
"language": "rnscript",
"scopeName": "source.rnscript",
"path": "./syntaxes/rnscript.tmLanguage.json"
}
]
},
"scripts": {
"vscode:prepublish": "yarn run compile",
"compile": "tsc -p ./ && node syntaxes/build",
"watch": "tsc -watch -p ./"
},
"devDependencies": {
"@types/vscode": "^1.63.0",
"@types/glob": "^7.1.3",
"@types/node": "14.x",
"glob": "^7.1.7",
"typescript": "^4.3.2"
}
}
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as vscode from 'vscode'

export function activate (context: vscode.ExtensionContext) {
}
43 changes: 43 additions & 0 deletions syntaxes/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { writeFileSync } = require('fs');

const ENTITY_NAME = '[A-Za-z_][A-Za-z0-9_]*';
function steppedRegExp (base, stairs, roof) {
let result = base;

for (const stair of stairs) result += '(?:(' + stair + ')';
result += ')?'.repeat(stairs.length);

if (roof) result += roof;
return result;
}

const rnscript = {
scopeName: "source.rnscript",
patterns: [
{
name: "entity.variable_declaration",
match: steppedRegExp('(let)(?:', ['<', ENTITY_NAME, ':|->', ENTITY_NAME], '(>))?\\s+'),
captures: {
"1": { name: "keyword.variable.let" },
"2": { name: "punctuation.type_params.open" },
"3": { name: "entity.name.type.namespace" },
"4": { name: "punctuation.separator.type_access" },
"5": { name: "support.type" },
"6": { name: "punctuation.type_params.close" }
}
},
{
name: "keyword.variable.let",
match: "let"
},
{
name: "keyword.other.this",
match: "this"
},
{ include: "source.lua" }
],
repository: {
}
};

writeFileSync(__dirname + '/rnscript.tmLanguage.json', JSON.stringify(rnscript, null, '\t'));
21 changes: 21 additions & 0 deletions syntaxes/rnscript.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"comments": {
"lineComment": "--"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "let<", "close": ">" },
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" }
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"]
]
}
41 changes: 41 additions & 0 deletions syntaxes/rnscript.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"scopeName": "source.rnscript",
"patterns": [
{
"name": "entity.variable_declaration",
"match": "(let)(?:(?:(<)(?:([A-Za-z_][A-Za-z0-9_]*)(?:(:|->)(?:([A-Za-z_][A-Za-z0-9_]*))?)?)?)?(>))?\\s+",
"captures": {
"1": {
"name": "keyword.variable.let"
},
"2": {
"name": "punctuation.type_params.open"
},
"3": {
"name": "entity.name.type.namespace"
},
"4": {
"name": "punctuation.separator.type_access"
},
"5": {
"name": "support.type"
},
"6": {
"name": "punctuation.type_params.close"
}
}
},
{
"name": "keyword.variable.let",
"match": "let"
},
{
"name": "keyword.other.this",
"match": "this"
},
{
"include": "source.lua"
}
],
"repository": {}
}
20 changes: 20 additions & 0 deletions test.rns
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@AllowGET()
@Middleware('session')
function index() {
set_header('A', 'b')

this->print(get_header('Host'))

let<rncore->number> test = '123'
let<rncore:table> result = {
a = test
}

let abc = 123

return this->json_data('text', false, result)
}

function b() {
return 1234
}
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"lib": [
"es6"
],
"sourceMap": true,
"rootDir": "src",
"strict": true /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
},
"exclude": [
"node_modules",
".vscode-test"
]
}

0 comments on commit da44a32

Please sign in to comment.