Fix interpreter and monaco
Browse files- Backend/GALinterpreter.py +4 -2
- UI/index.html +1 -1
- UI/main.js +10 -11
Backend/GALinterpreter.py
CHANGED
|
@@ -715,8 +715,10 @@ class Interpreter:
|
|
| 715 |
|
| 716 |
def _parse_literal(self, value):
|
| 717 |
|
| 718 |
-
if isinstance(value, str)
|
| 719 |
-
|
|
|
|
|
|
|
| 720 |
|
| 721 |
if isinstance(value, (int, float, bool)):
|
| 722 |
return value
|
|
|
|
| 715 |
|
| 716 |
def _parse_literal(self, value):
|
| 717 |
|
| 718 |
+
if isinstance(value, str):
|
| 719 |
+
var_info = self.lookup_variable(value)
|
| 720 |
+
if var_info is not None and not isinstance(var_info, str):
|
| 721 |
+
return var_info["value"]
|
| 722 |
|
| 723 |
if isinstance(value, (int, float, bool)):
|
| 724 |
return value
|
UI/index.html
CHANGED
|
@@ -202,7 +202,7 @@
|
|
| 202 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.43.0/min/vs/loader.js"></script> <!-- Monaco editor -->
|
| 203 |
|
| 204 |
|
| 205 |
-
<script src="main.js?v=
|
| 206 |
|
| 207 |
|
| 208 |
<script>
|
|
|
|
| 202 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.43.0/min/vs/loader.js"></script> <!-- Monaco editor -->
|
| 203 |
|
| 204 |
|
| 205 |
+
<script src="main.js?v=20260331a"></script>
|
| 206 |
|
| 207 |
|
| 208 |
<script>
|
UI/main.js
CHANGED
|
@@ -166,11 +166,10 @@
|
|
| 166 |
});
|
| 167 |
|
| 168 |
// Add line highlighting on click
|
| 169 |
-
let
|
| 170 |
editor.onDidChangeCursorPosition((e) => {
|
| 171 |
const lineNumber = e.position.lineNumber;
|
| 172 |
-
|
| 173 |
-
currentLineDecorations = editor.deltaDecorations(currentLineDecorations, [
|
| 174 |
{
|
| 175 |
range: new monaco.Range(lineNumber, 1, lineNumber, 1),
|
| 176 |
options: {
|
|
@@ -185,7 +184,7 @@
|
|
| 185 |
// (reverted) no status bar cursor updates
|
| 186 |
|
| 187 |
// ββ Bracket mismatch highlighting ββ
|
| 188 |
-
let
|
| 189 |
const BRACKET_PAIRS = { '(': ')', '[': ']', '{': '}' };
|
| 190 |
const CLOSE_TO_OPEN = { ')': '(', ']': '[', '}': '{' };
|
| 191 |
|
|
@@ -246,11 +245,11 @@
|
|
| 246 |
overviewRuler: { color: '#ff3322', position: monaco.editor.OverviewRulerLane.Center }
|
| 247 |
}
|
| 248 |
}));
|
| 249 |
-
|
| 250 |
}
|
| 251 |
|
| 252 |
// ββ Missing semicolon detection ββ
|
| 253 |
-
let
|
| 254 |
|
| 255 |
function findMissingSemicolons(text) {
|
| 256 |
const lines = text.split('\n');
|
|
@@ -310,7 +309,7 @@
|
|
| 310 |
overviewRuler: { color: '#ff9900', position: monaco.editor.OverviewRulerLane.Center }
|
| 311 |
}
|
| 312 |
}));
|
| 313 |
-
|
| 314 |
}
|
| 315 |
|
| 316 |
editor.onDidChangeModelContent(() => {
|
|
@@ -323,7 +322,7 @@
|
|
| 323 |
updateSemicolonWarnings();
|
| 324 |
|
| 325 |
// ββ Error line highlighting ββ
|
| 326 |
-
let
|
| 327 |
|
| 328 |
// Parse error string for line/col: supports "LEXICAL/SYNTAX error line X col Y" and "Ln X Semantic Error"
|
| 329 |
function parseErrorLocations(errors) {
|
|
@@ -343,7 +342,7 @@
|
|
| 343 |
window._highlightErrors = function(errors) {
|
| 344 |
const locs = parseErrorLocations(errors);
|
| 345 |
if (!locs.length) {
|
| 346 |
-
|
| 347 |
monaco.editor.setModelMarkers(window.editor.getModel(), 'gal-errors', []);
|
| 348 |
return;
|
| 349 |
}
|
|
@@ -358,7 +357,7 @@
|
|
| 358 |
hoverMessage: { value: loc.msg }
|
| 359 |
}
|
| 360 |
}));
|
| 361 |
-
|
| 362 |
// Also set model markers (squiggly red underlines)
|
| 363 |
const markers = locs.map(loc => ({
|
| 364 |
severity: monaco.MarkerSeverity.Error,
|
|
@@ -376,7 +375,7 @@
|
|
| 376 |
};
|
| 377 |
|
| 378 |
window._clearErrorHighlights = function() {
|
| 379 |
-
|
| 380 |
monaco.editor.setModelMarkers(window.editor.getModel(), 'gal-errors', []);
|
| 381 |
};
|
| 382 |
});
|
|
|
|
| 166 |
});
|
| 167 |
|
| 168 |
// Add line highlighting on click
|
| 169 |
+
let currentLineDecCollection = editor.createDecorationsCollection([]);
|
| 170 |
editor.onDidChangeCursorPosition((e) => {
|
| 171 |
const lineNumber = e.position.lineNumber;
|
| 172 |
+
currentLineDecCollection.set([
|
|
|
|
| 173 |
{
|
| 174 |
range: new monaco.Range(lineNumber, 1, lineNumber, 1),
|
| 175 |
options: {
|
|
|
|
| 184 |
// (reverted) no status bar cursor updates
|
| 185 |
|
| 186 |
// ββ Bracket mismatch highlighting ββ
|
| 187 |
+
let bracketDecCollection = editor.createDecorationsCollection([]);
|
| 188 |
const BRACKET_PAIRS = { '(': ')', '[': ']', '{': '}' };
|
| 189 |
const CLOSE_TO_OPEN = { ')': '(', ']': '[', '}': '{' };
|
| 190 |
|
|
|
|
| 245 |
overviewRuler: { color: '#ff3322', position: monaco.editor.OverviewRulerLane.Center }
|
| 246 |
}
|
| 247 |
}));
|
| 248 |
+
bracketDecCollection.set(decs);
|
| 249 |
}
|
| 250 |
|
| 251 |
// ββ Missing semicolon detection ββ
|
| 252 |
+
let semicolonDecCollection = editor.createDecorationsCollection([]);
|
| 253 |
|
| 254 |
function findMissingSemicolons(text) {
|
| 255 |
const lines = text.split('\n');
|
|
|
|
| 309 |
overviewRuler: { color: '#ff9900', position: monaco.editor.OverviewRulerLane.Center }
|
| 310 |
}
|
| 311 |
}));
|
| 312 |
+
semicolonDecCollection.set(decs);
|
| 313 |
}
|
| 314 |
|
| 315 |
editor.onDidChangeModelContent(() => {
|
|
|
|
| 322 |
updateSemicolonWarnings();
|
| 323 |
|
| 324 |
// ββ Error line highlighting ββ
|
| 325 |
+
let errorDecCollection = editor.createDecorationsCollection([]);
|
| 326 |
|
| 327 |
// Parse error string for line/col: supports "LEXICAL/SYNTAX error line X col Y" and "Ln X Semantic Error"
|
| 328 |
function parseErrorLocations(errors) {
|
|
|
|
| 342 |
window._highlightErrors = function(errors) {
|
| 343 |
const locs = parseErrorLocations(errors);
|
| 344 |
if (!locs.length) {
|
| 345 |
+
errorDecCollection.set([]);
|
| 346 |
monaco.editor.setModelMarkers(window.editor.getModel(), 'gal-errors', []);
|
| 347 |
return;
|
| 348 |
}
|
|
|
|
| 357 |
hoverMessage: { value: loc.msg }
|
| 358 |
}
|
| 359 |
}));
|
| 360 |
+
errorDecCollection.set(decorations);
|
| 361 |
// Also set model markers (squiggly red underlines)
|
| 362 |
const markers = locs.map(loc => ({
|
| 363 |
severity: monaco.MarkerSeverity.Error,
|
|
|
|
| 375 |
};
|
| 376 |
|
| 377 |
window._clearErrorHighlights = function() {
|
| 378 |
+
errorDecCollection.set([]);
|
| 379 |
monaco.editor.setModelMarkers(window.editor.getModel(), 'gal-errors', []);
|
| 380 |
};
|
| 381 |
});
|