diff --git a/sjscript/src/sjscript/Token.d b/sjscript/src/sjscript/Token.d index 0bdb0d4..6bc955f 100644 --- a/sjscript/src/sjscript/Token.d +++ b/sjscript/src/sjscript/Token.d @@ -64,12 +64,17 @@ enum TokenType { @TextCompleteMatcher!"{" OpenBrace, @TextCompleteMatcher!"}" CloseBrace, + @TextCompleteMatcher!"[" OpenBracket, + @TextCompleteMatcher!"]" CloseBracket, + @TextCompleteMatcher!"(" OpenParen, @TextCompleteMatcher!")" CloseParen, @TextCompleteMatcher!"," Comma, @TextCompleteMatcher!";" SemiColon, + @TextCompleteMatcher!".." DoubleDot, + @TextCompleteMatcher!"=" Assign, @TextCompleteMatcher!"+=" AddAssign, diff --git a/sjscript/src/sjscript/parse.d b/sjscript/src/sjscript/parse.d index 42eb999..85b23af 100644 --- a/sjscript/src/sjscript/parse.d +++ b/sjscript/src/sjscript/parse.d @@ -1,6 +1,8 @@ /// License: MIT module sjscript.parse; +import std.conv; + import dast.parse; import sjscript.Expression, @@ -13,7 +15,7 @@ unittest { import dast.tokenize : Tokenize; enum src = q"EOS - framebuffer 0 { + framebuffer [0..5] { a = 0; b += 0; } @@ -60,8 +62,14 @@ private class RuleSet { target.text, period, params, CreateTokenPos(target, closebrace)); } - static Period ParsePeriod(@(TokenType.Number) Token) { // TODO - return Period(0, 0); + static Period ParsePeriod( + @(TokenType.OpenBracket) Token, + @(TokenType.Number) Token begin, + @(TokenType.DoubleDot) Token, + @(TokenType.Number) Token end, + @(TokenType.CloseBracket) Token) { + return Period( + begin.text.to!float.to!int, end.text.to!float.to!int); } static Parameter[] ParseParameterListFirstItem(Parameter param) {