diff --git a/AutoUpdater.xml b/AutoUpdater.xml index 6c07b03..4d627bd 100644 --- a/AutoUpdater.xml +++ b/AutoUpdater.xml @@ -1,6 +1,6 @@ - 1.2.0.1 + 1.2.1.0 https://github.com/PocketMiner82/pseudocode-ide/releases/latest/download/pseudocode-ide.zip https://github.com/PocketMiner82/pseudocode-ide/releases false diff --git a/SolutionInfo.cs b/SolutionInfo.cs index 8dca432..89d88ce 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("1.2.0.1")] -[assembly: AssemblyFileVersion("1.2.0.1")] +[assembly: AssemblyVersion("1.2.1.0")] +[assembly: AssemblyFileVersion("1.2.1.0")] diff --git a/pseudocodeIde/PseudocodeIDEForm.cs b/pseudocodeIde/PseudocodeIDEForm.cs index c47eb66..e430618 100644 --- a/pseudocodeIde/PseudocodeIDEForm.cs +++ b/pseudocodeIde/PseudocodeIDEForm.cs @@ -227,8 +227,8 @@ private void codeTextBox_TextChanged(object sender, EventArgs e) private void codeTextBox_KeyDown(object sender, KeyEventArgs e) { - // ignore CTRL[+SHIFT]+(Z/Y/L/R/E) - if ((e.KeyCode == Keys.Z || e.KeyCode == Keys.Y || e.KeyCode == Keys.L || e.KeyCode == Keys.R || e.KeyCode == Keys.E) + // ignore CTRL[+SHIFT]+(Z/Y/L/R/E/S) + if ((e.KeyCode == Keys.Z || e.KeyCode == Keys.Y || e.KeyCode == Keys.L || e.KeyCode == Keys.R || e.KeyCode == Keys.E || e.KeyCode == Keys.S) && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == (Keys.Control | Keys.Shift))) { e.SuppressKeyPress = true; diff --git a/pseudocodeIde/interpreter/parser/Parser.cs b/pseudocodeIde/interpreter/parser/Parser.cs index cb621f1..1f491da 100644 --- a/pseudocodeIde/interpreter/parser/Parser.cs +++ b/pseudocodeIde/interpreter/parser/Parser.cs @@ -289,7 +289,7 @@ private string handleDoWhile() do { this.advance(); - output += this.parseToken(output.LastOrDefault(), true); + output += this.parseToken(output.LastOrDefault()); currentToken = this.peek(); } while (!this.isAtEnd() && currentToken.type != WHILE); diff --git a/pseudocodeIde/interpreter/scanner/Scanner.cs b/pseudocodeIde/interpreter/scanner/Scanner.cs index a8785b3..878ba03 100644 --- a/pseudocodeIde/interpreter/scanner/Scanner.cs +++ b/pseudocodeIde/interpreter/scanner/Scanner.cs @@ -1,5 +1,7 @@ using pseudocodeIde.interpreter.logging; +using System; using System.Collections.Generic; +using System.Diagnostics; using static pseudocodeIde.interpreter.TokenType; namespace pseudocodeIde.interpreter @@ -184,17 +186,24 @@ private void scanToken() case '\'': this.handleChar(); break; default: - if (this.isDigit(c)) + try { - this.handleNumber(); - } - else if (this.isAlpha(c)) - { - this.handleIdentifier(); + if (this.isDigit(c)) + { + this.handleNumber(); + } + else if (this.isAlpha(c)) + { + this.handleIdentifier(); + } + else + { + Logger.error(this.line, $"Unerwartetes Zeichen: '{c}'."); + } } - else + catch (Exception e) { - Logger.error(this.line, $"Unerwartetes Zeichen: '{c}'."); + Logger.error(this.line, $"Unerwartete Zeichen nach '{c}'. {e.GetType().Name}: {e.Message}"); } break; } @@ -286,6 +295,32 @@ private void handleNumber() this.advance(); } } + else if (this.peek() == 'x' && this.isHexDigit(this.peekNext())) + { + // consume the 'x' + this.advance(); + + while (this.isHexDigit(this.peek())) + { + this.advance(); + } + // start + 2 because the '0x' must be removed + this.addToken(NUMBER, Convert.ToInt32(this.code.Substring(this.start + 2, this.current - this.start), 16)); + return; + } + else if (this.peek() == 'b' && this.isBinaryDigit(this.peekNext())) + { + // consume the 'b' + this.advance(); + + while (this.isBinaryDigit(this.peek())) + { + this.advance(); + } + // start + 2 because the '0b' must be removed + this.addToken(NUMBER, Convert.ToInt32(this.code.Substring(this.start, this.current - this.start).Substring(2), 2)); + return; + } this.addToken(NUMBER, double.Parse(this.code.Substring(this.start, this.current - this.start))); } @@ -394,6 +429,18 @@ private bool isDigit(char c) return c >= '0' && c <= '9'; } + private bool isHexDigit(char c) + { + return isDigit(c) || + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F'); + } + + private bool isBinaryDigit(char c) + { + return c == '0' || c == '1'; + } + private bool isAlpha(char c) { return (c >= 'a' && c <= 'z') ||