Skip to content

Commit

Permalink
Changed integer division operator to '\'
Browse files Browse the repository at this point in the history
  • Loading branch information
Enichan committed Jul 26, 2019
1 parent cdf16ee commit 9cde12a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Depicofier/ConcreteCombinedLuaListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
12 changes: 12 additions & 0 deletions Depicofier/LuaListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
4 changes: 2 additions & 2 deletions Depicofier/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 3 additions & 1 deletion P8LuaGrammar/CombinedLua.g4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -223,8 +224,9 @@ operatorStrcat
operatorAddSub
: '+' | '-';

// changed the // operator to \ so it doesn't conflict with pico 8 alternative comment syntax
operatorMulDivMod
: '*' | '/' | '%' | '//';
: '*' | '/' | '%' | '\\';

operatorBitwise
: '&' | '|' | '~' | '<<' | '>>';
Expand Down
4 changes: 2 additions & 2 deletions P8LuaGrammar/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit 9cde12a

Please sign in to comment.