From 17c410eae242575f7f5e2cfeccfa7081f585e85e Mon Sep 17 00:00:00 2001 From: John Date: Thu, 14 Apr 2022 14:27:07 -0500 Subject: [PATCH] Oops: Upload all files changed on VM in the last 5 days. Commit info lost. --- src/commands/hub.ts | 9 +++++---- src/commands/text.ts | 16 +++++++++++----- src/pylex/lexer.ts | 20 +++++++++----------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/commands/hub.ts b/src/commands/hub.ts index d9bf735..55c9c3a 100755 --- a/src/commands/hub.ts +++ b/src/commands/hub.ts @@ -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 { ev3 = await EV3Manager.activate(); ev3.test(); } - +*/ async function connectHub(): Promise { if (hub && hub.isOpen()) { vscode.window.showWarningMessage('LEGO Hub is already connected, reconnecting...'); diff --git a/src/commands/text.ts b/src/commands/text.ts index e881b60..6c0cae2 100755 --- a/src/commands/text.ts +++ b/src/commands/text.ts @@ -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()}`; } } } diff --git a/src/pylex/lexer.ts b/src/pylex/lexer.ts index 9135aeb..92e48ea 100644 --- a/src/pylex/lexer.ts +++ b/src/pylex/lexer.ts @@ -56,6 +56,14 @@ const rules: Rule[] = [ pattern: /^\s*with\s+(?[^:]+):\s*$/, type: Symbol.WITH }, + { + pattern: /^\s*(#.*)?$/, + type: Symbol.EMPTY + }, + { + pattern: /\s*(?[^#]+)?$/, + 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); - } - + token = new LineToken(Symbol.EMPTY, this.pos, 999999); this._currToken = token; this.pos++;