[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Adding new operators
- From: Patrick Kurth <p.kurth@...>
- Date: Tue, 18 Jan 2022 11:48:03 +0000
at which places do I have to modify code to add new operators?
I quite often need a // b and a // b + 1 so i thought about adding /+
and /-, where /- is like // (only added for symmetry). I'm not sure if
I think this is a good idea, but it seemed easy enough to try out.
Well, obviously you have to add a new token, the parser has to omit the
right operation, the opcode has to exit, the virtual machine has to be
edited and the code generator has to be updated. That means changes in
lstrlib.c -- duh
Ok, that's more than I expected, anything else to look for? The
required changes seem simple enough.
And one more question: the 'K' suffix in opcodes denotes constant
operands, but at what point does a // 2 becomes OP_IDIVK? The lexer
only emits TK_IDIV.