Adding String data type to CNS/ZSS #964
Replies: 6 comments 4 replies
-
I'm not sure about how to go about implementing it, but I can provide one application for it I wish were possible to maybe give you some ideas:
Ideally those MAF and MA wouldn't need format specifiers before them. |
Beta Was this translation helpful? Give feedback.
-
The biggest usefulness for this I can think of, in current creations, is to truly detect character names within reason via InString stuff. Right now, if we want to detect a "Ryu", we have to go for "Ryu", "Ryu Hoshi", "Hoshi Ryu", "Ryuu", and every other variant all the way to "El Chabón que Jadoquens". This is impressive. |
Beta Was this translation helpful? Give feedback.
-
Another issue that has presented is the inconsistency on how CNS/ZSS currently handles strings. There are situations where strings are parsed only if they're enclosed in quotation marks (like SCTRLs, for example), but, in cases like arguments on function-like triggers (like This makes me think we should add "versions" to ZSS, much like Lua, Sff, Fnt, etc. In its most recent version, syntax will be more consistent with its rules, mainly in String-related stuff. After discussing the idea a little bit in the discord server with other users, I considered three possible major versions:
ZSS version can be declared at the start of a .zss file, with syntax like this:
(In this case, we're using major ver. 2, with additional numbers for possible minor versions) |
Beta Was this translation helpful? Give feedback.
-
Some days ago I was able to make some progress regarding the compiler. First, I found raw numbers are compiled as BytecodeValues through Following that, I changed clipboard SCTRL code so a BytecodeValue of type displayToClipboard{
text: "%v";
params: "hello there";
} Code for all of this can be found in 43e5f93. Next, I wanted to experiment with character maps, to see if they could hold string values, no matter if it's in the most rudimentary process possible. I got great results by using interfaces in the chars' hashmaps and doing type assertion in the bytecode machine, which got me into these results: map(someStr) := "I'm saving this string for later";
displayToClipboard{
text: "%v";
params: map(someStr);
} For my last experiment, I decided to unhardcode Code for all this (including defective string equality comparison) can be found here: 0204496. |
Beta Was this translation helpful? Give feedback.
-
OK, so, coming back to this. I'll list all the State Controllers and Triggers that should be un-hardcoded (in theory). State Controllers:
Triggers:
|
Beta Was this translation helpful? Give feedback.
-
Strings could be concatenated through an operator. We can use '+' (consistent with our current operators). List of proposed data assertion triggers/methods
List of proposed String manipulation triggers/methods:
|
Beta Was this translation helpful? Give feedback.
-
Right now, Ikemen's bytecode machine only handles strings for certain isolated situations, like comparison of
name
trigger or certain parameters in SCTRLs, likeText
orDisplayToClipboard
. This makes string support in character code essentially hardcoded. By adding strings as a new data type that can be manipulated in the code, we're unhardcoding an essential part of coding. We'll be able to create custom, dynamically-changing texts withText
SCTRL, store strings in maps, do BGM changes with only onePlayBGM
, produce more understandable code, etc.Bytecode seems like the easiest part to implement. To add basic string support, the first idea I had was the next:
VT_String
, which will store an index of the StringPool where the string is locatedToS()
,SetS()
,PushS()
,EvalS()
,BytecodeString()
)OC_string
OpCode to push a string from the compiled code to the stackAfter all this, relevant parts of the bytecode machine can be rewritten to use these new methods and ensure proper handling of strings at runtime. Here's an example commit where I apply all this: Lazin3ss@964a8f1
Now, the most troublesome part is the compiler. Current compiler code is kind of a mess, with a mix of japanese and english in identifier naming and most of the code being designed with only numbers in mind. This means all instances of string parsing are reduced to its hardcorded situations, like the ones described at the start of this post. A deep refactor of current compiler code is necessary so strings can be parsed in a more general way.
Beta Was this translation helpful? Give feedback.
All reactions