From 16aeda86122518a3382b960f1a430e168e62f5ac Mon Sep 17 00:00:00 2001 From: falsycat Date: Mon, 14 Oct 2019 00:00:00 +0000 Subject: [PATCH] [update] Allowed a parser to parse the first term with minus. --- sjscript/src/sjscript/parse.d | 4 ++++ sjscript/test/test02.sj | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sjscript/src/sjscript/parse.d b/sjscript/src/sjscript/parse.d index a44ee05..9435c4a 100644 --- a/sjscript/src/sjscript/parse.d +++ b/sjscript/src/sjscript/parse.d @@ -120,6 +120,10 @@ private class RuleSet { static Expression ParseExpressionFromFirstTerm(Term term) { return Expression([term]); } + static Expression ParseExpressionFromFirstNegativeTerm( + @(TokenType.Sub) Token, Term term) { + return Expression([term * -1f]); + } static Expression ParseExpressionFromFollowingAddedTerm( Expression expr, @(TokenType.Add) Token, Term term) { return expr + term; diff --git a/sjscript/test/test02.sj b/sjscript/test/test02.sj index 27df68e..a070c12 100644 --- a/sjscript/test/test02.sj +++ b/sjscript/test/test02.sj @@ -2,6 +2,6 @@ $define beat {0} $repeat i 100 { A [$i*5+$beat..($i+1)*5+$beat] { - damage = 1; + damage = -1; } }