From 9cde12a90fd157f81c25133bf4b3a0ff41faa2f8 Mon Sep 17 00:00:00 2001 From: Eniko Date: Fri, 26 Jul 2019 11:06:40 -0500 Subject: [PATCH] Changed integer division operator to '\' --- Depicofier/ConcreteCombinedLuaListener.cs | 4 ++++ Depicofier/LuaListener.cs | 12 ++++++++++++ Depicofier/Properties/AssemblyInfo.cs | 4 ++-- P8LuaGrammar/CombinedLua.g4 | 4 +++- P8LuaGrammar/Properties/AssemblyInfo.cs | 4 ++-- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Depicofier/ConcreteCombinedLuaListener.cs b/Depicofier/ConcreteCombinedLuaListener.cs index 2b5b8f0..76c055c 100644 --- a/Depicofier/ConcreteCombinedLuaListener.cs +++ b/Depicofier/ConcreteCombinedLuaListener.cs @@ -22,5 +22,9 @@ public override void EnterOperatorComparison([NotNull] CombinedLuaParser.Operato public override void EnterNumber([NotNull] CombinedLuaParser.NumberContext context) { Parent.EnterNumber(context); } + + public override void EnterOperatorMulDivMod([NotNull] CombinedLuaParser.OperatorMulDivModContext context) { + Parent.EnterOperatorMulDivMod(context); + } } } diff --git a/Depicofier/LuaListener.cs b/Depicofier/LuaListener.cs index 9c37bcf..ecd53fc 100644 --- a/Depicofier/LuaListener.cs +++ b/Depicofier/LuaListener.cs @@ -96,6 +96,18 @@ public virtual void EnterOperatorComparison([NotNull] ParserRuleContext context) } } + public virtual void EnterOperatorMulDivMod([NotNull] ParserRuleContext context) { + if (context.GetText() == "\\") { + Replacements.Push( + new Replacement( + context.start.StartIndex, + context.stop.StopIndex, + "//" + ) + ); + } + } + public void EnterNumber([NotNull] ParserRuleContext context) { var literal = context.GetText().ToLowerInvariant(); if (literal.StartsWith("0b")) { diff --git a/Depicofier/Properties/AssemblyInfo.cs b/Depicofier/Properties/AssemblyInfo.cs index 9aea703..7d3183d 100644 --- a/Depicofier/Properties/AssemblyInfo.cs +++ b/Depicofier/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.1.0")] +[assembly: AssemblyFileVersion("0.1.1.0")] diff --git a/P8LuaGrammar/CombinedLua.g4 b/P8LuaGrammar/CombinedLua.g4 index 1d36615..e167ae7 100644 --- a/P8LuaGrammar/CombinedLua.g4 +++ b/P8LuaGrammar/CombinedLua.g4 @@ -54,6 +54,7 @@ Modified for Pico 8 syntax by Eniko - https://github.com/enichan // - != operator alias for ~= // - '?' shorthand for print (though only at the start of a line) // - binary number literals 0b11010101.101010 +// - integer division now uses \ instead of // (which indicates a comment in pico 8) // // not implemented: // - single line if: 'if' '(' exp ')' block ('else' block)? followed by line end @@ -223,8 +224,9 @@ operatorStrcat operatorAddSub : '+' | '-'; +// changed the // operator to \ so it doesn't conflict with pico 8 alternative comment syntax operatorMulDivMod - : '*' | '/' | '%' | '//'; + : '*' | '/' | '%' | '\\'; operatorBitwise : '&' | '|' | '~' | '<<' | '>>'; diff --git a/P8LuaGrammar/Properties/AssemblyInfo.cs b/P8LuaGrammar/Properties/AssemblyInfo.cs index 93476a7..0725e84 100644 --- a/P8LuaGrammar/Properties/AssemblyInfo.cs +++ b/P8LuaGrammar/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.1.0")] +[assembly: AssemblyFileVersion("1.0.1.0")]