[grammar] update

This commit is contained in:
2021-04-09 23:40:13 +05:30
parent 65cd9dba24
commit 3d8fc0c74a
6 changed files with 15 additions and 37 deletions

View File

@@ -8,6 +8,7 @@ A simple language server for Brainfuck based on the example.
- [X] Syntax
- [X] Bracket matching
- [X] Autocomplete suggestions
- [ ] Extension icon
<!--
## Structure

View File

@@ -4,15 +4,15 @@
"blockComment":["/*","*/"]
},
"brackets":[
["(",")"]
["[","]"]
],
"autoClosingPairs":[
["(",")"]
["[","]"]
],
"surroundingPairs":[
["(",")"]
["[","]"]
],
"folding": {
"_folding": {
"markers": {
"start": "^\\s*(//)|(--)\\s*#?region\\b",
"end": "^\\s*(//)|(--)\\s*#?endregion\\b"

View File

@@ -39,11 +39,7 @@ export function activate(context: ExtensionContext) {
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{ scheme: 'file', language: 'bf' }],
synchronize: {
// Notify the server about file changes to '.clientrc files contained in the workspace
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
}
documentSelector: [{ scheme: 'file', language: 'bf' }]
};

View File

@@ -8,7 +8,9 @@
"version": "0.0.1",
"categories": [],
"keywords": [
"multi-root ready"
"multi-root ready",
"brainfuck",
"branflakes"
],
"prettier":{
"tabWidth": 4,

View File

@@ -151,10 +151,10 @@ const validateBrackets = (text: string) => {
let count = 0, lp: number[] = [],issues:number[]=[];
const textsplit = text.split(``);
textsplit.forEach((x, i) => {
if (x == '(' || x == ')') {
if (x == '[' || x == ']') {
if (x == '(') lp.push(i);
if (x == ')') {if(lp.length==0) issues.push(i);lp.pop();}
if (x == '[') lp.push(i);
if (x == ']') {if(lp.length==0) issues.push(i);lp.pop();}
}
@@ -181,7 +181,7 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
end: textDocument.positionAt(e+1),
},
severity:DiagnosticSeverity.Error,
code:'( and )',
code:'[ and ]',
})));
// diagnostics.push({
@@ -207,11 +207,6 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
}
connection.onDidChangeWatchedFiles(_change => {
// Monitored files have change in VSCode
connection.console.log('We received an file change event');
});
// This handler provides the initial list of the completion items.
connection.onCompletion(
(_textDocumentPosition: TextDocumentPositionParams): CompletionItem[] => {
@@ -254,22 +249,6 @@ connection.onCompletion(
}
);
//TODOF Implement further
// This handler resolves additional information for the item selected in
// the completion list.
// connection.onCompletionResolve(
// (item: CompletionItem): CompletionItem => {
// if (item.data === 1) {
// item.detail = 'Addition';
// item.documentation = 'Add 1 to the cell';
// } else if (item.data === 2) {
// item.detail = 'Subtraction';
// item.documentation = 'Subtract 1 from the cell';
// }
// return item;
// }
// );
// Make the text document manager listen on the connection
// for open, change and close text document events

View File

@@ -51,8 +51,8 @@
"name":"keyword.operator.output"
},
"paren-expression": {
"begin": "\\(",
"end": "\\)",
"begin": "\\[",
"end": "\\]",
"beginCaptures": {
"0": {
"name": "punctuation.paren.open"