mirror of
https://github.com/We-Dont-Byte/Mind_Reader.git
synced 2024-11-15 03:35:59 +00:00
Oops: Upload all files changed on VM in the last 5 days. Commit info lost.
This commit is contained in:
parent
de3c9bf435
commit
17c410eae2
@ -1,7 +1,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import HubManager from '../hubManager';
|
||||
import EV3Manager from '../ev3Manager';
|
||||
//import EV3Manager from '../ev3Manager';
|
||||
|
||||
import { CommandEntry } from './commandEntry';
|
||||
|
||||
@ -34,22 +34,23 @@ export const hubCommands: CommandEntry[] = [
|
||||
{
|
||||
name: 'mind-reader.deleteProgram',
|
||||
callback: deleteProgram
|
||||
},
|
||||
}/*,
|
||||
{
|
||||
name: 'mind-reader.ev3.test',
|
||||
callback: ev3test
|
||||
}
|
||||
}*/
|
||||
];
|
||||
|
||||
// Current connected hub
|
||||
let hub: HubManager | null = null;
|
||||
/*
|
||||
let ev3: EV3Manager | null = null;
|
||||
|
||||
async function ev3test(): Promise<void> {
|
||||
ev3 = await EV3Manager.activate();
|
||||
ev3.test();
|
||||
}
|
||||
|
||||
*/
|
||||
async function connectHub(): Promise<void> {
|
||||
if (hub && hub.isOpen()) {
|
||||
vscode.window.showWarningMessage('LEGO Hub is already connected, reconnecting...');
|
||||
|
@ -167,23 +167,29 @@ function createContextString(context: pl.LexNode[], line: number): string {
|
||||
let contextString: string = `Line ${line + 1}`; // 1 based
|
||||
|
||||
if (context[0].token && context[0].token.attr) {
|
||||
contextString += ': ' + context[0].token.type.toString() + ' ' + context[0].token.attr.toString();
|
||||
let tokenTypeString: string = ` ${context[0].token.type.toString()}`;
|
||||
contextString += `:${tokenTypeString !== 'INDENT'?tokenTypeString:" "
|
||||
} ${context[0].token.attr.toString()}`;
|
||||
}
|
||||
|
||||
for (let i: number = 1; i < context.length; i++) {
|
||||
const node: pl.LexNode = context[i];
|
||||
|
||||
const inside: string = "in";
|
||||
if (node.label === 'root') {
|
||||
// root
|
||||
contextString += ' in the Document Root';
|
||||
if (vscode.window.activeTextEditor?.document.uri) {
|
||||
contextString += ` ${inside} ${vscode.workspace.asRelativePath(vscode.window.activeTextEditor?.document.uri)}`;
|
||||
} else {
|
||||
contextString += ` ${inside} the Document`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node.token && node.token.type !== pl.PylexSymbol.EMPTY &&
|
||||
node.token.type !== pl.PylexSymbol.INDENT) {
|
||||
contextString += ' inside ' + node.token.type.toString();
|
||||
contextString += ` ${inside} ${node.token.type.toString()}`;
|
||||
if (node.token.attr) {
|
||||
contextString += ' ' + node.token.attr.toString();
|
||||
contextString += ` ${node.token.attr.toString()}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,14 @@ const rules: Rule[] = [
|
||||
pattern: /^\s*with\s+(?<attr>[^:]+):\s*$/,
|
||||
type: Symbol.WITH
|
||||
},
|
||||
{
|
||||
pattern: /^\s*(#.*)?$/,
|
||||
type: Symbol.EMPTY
|
||||
},
|
||||
{
|
||||
pattern: /\s*(?<attr>[^#]+)?$/,
|
||||
type: Symbol.INDENT
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
@ -143,17 +151,7 @@ export default class Lexer {
|
||||
}
|
||||
}
|
||||
// No rules matched
|
||||
|
||||
// TODO: move to rules
|
||||
if (/^\s*(#.*)?$/.test(line)) {
|
||||
// "empty" line
|
||||
token = new LineToken(Symbol.EMPTY, this.pos, 999999);
|
||||
}
|
||||
else {
|
||||
// This is an INDENT token
|
||||
token = new LineToken(Symbol.INDENT, this.pos, indent);
|
||||
}
|
||||
|
||||
this._currToken = token;
|
||||
this.pos++;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user