Oops: Upload all files changed on VM in the last 5 days. Commit info lost.

This commit is contained in:
John 2022-04-14 14:27:07 -05:00
parent de3c9bf435
commit 17c410eae2
3 changed files with 25 additions and 20 deletions

View File

@ -1,7 +1,7 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import * as path from 'path'; import * as path from 'path';
import HubManager from '../hubManager'; import HubManager from '../hubManager';
import EV3Manager from '../ev3Manager'; //import EV3Manager from '../ev3Manager';
import { CommandEntry } from './commandEntry'; import { CommandEntry } from './commandEntry';
@ -34,22 +34,23 @@ export const hubCommands: CommandEntry[] = [
{ {
name: 'mind-reader.deleteProgram', name: 'mind-reader.deleteProgram',
callback: deleteProgram callback: deleteProgram
}, }/*,
{ {
name: 'mind-reader.ev3.test', name: 'mind-reader.ev3.test',
callback: ev3test callback: ev3test
} }*/
]; ];
// Current connected hub // Current connected hub
let hub: HubManager | null = null; let hub: HubManager | null = null;
/*
let ev3: EV3Manager | null = null; let ev3: EV3Manager | null = null;
async function ev3test(): Promise<void> { async function ev3test(): Promise<void> {
ev3 = await EV3Manager.activate(); ev3 = await EV3Manager.activate();
ev3.test(); ev3.test();
} }
*/
async function connectHub(): Promise<void> { async function connectHub(): Promise<void> {
if (hub && hub.isOpen()) { if (hub && hub.isOpen()) {
vscode.window.showWarningMessage('LEGO Hub is already connected, reconnecting...'); vscode.window.showWarningMessage('LEGO Hub is already connected, reconnecting...');

View File

@ -167,23 +167,29 @@ function createContextString(context: pl.LexNode[], line: number): string {
let contextString: string = `Line ${line + 1}`; // 1 based let contextString: string = `Line ${line + 1}`; // 1 based
if (context[0].token && context[0].token.attr) { 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++) { for (let i: number = 1; i < context.length; i++) {
const node: pl.LexNode = context[i]; const node: pl.LexNode = context[i];
const inside: string = "in";
if (node.label === 'root') { if (node.label === 'root') {
// 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; continue;
} }
if (node.token && node.token.type !== pl.PylexSymbol.EMPTY && if (node.token && node.token.type !== pl.PylexSymbol.EMPTY &&
node.token.type !== pl.PylexSymbol.INDENT) { node.token.type !== pl.PylexSymbol.INDENT) {
contextString += ' inside ' + node.token.type.toString(); contextString += ` ${inside} ${node.token.type.toString()}`;
if (node.token.attr) { if (node.token.attr) {
contextString += ' ' + node.token.attr.toString(); contextString += ` ${node.token.attr.toString()}`;
} }
} }
} }

View File

@ -56,6 +56,14 @@ const rules: Rule[] = [
pattern: /^\s*with\s+(?<attr>[^:]+):\s*$/, pattern: /^\s*with\s+(?<attr>[^:]+):\s*$/,
type: Symbol.WITH 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 // No rules matched
// TODO: move to rules
if (/^\s*(#.*)?$/.test(line)) {
// "empty" line
token = new LineToken(Symbol.EMPTY, this.pos, 999999); 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._currToken = token;
this.pos++; this.pos++;