This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
KillaVanilla's profile picture

Operator Replacer

Started by KillaVanilla, 24 November 2012 - 10:20 AM
KillaVanilla #1
Posted 24 November 2012 - 11:20 AM
Hello all.

This small program automatically replaces any occurrences of the augmented-assignment operators (+=, -=, etc), with the longer forms (x = x + y, x = x - y).

It takes only one parameter (the file to modify), and writes the output to a file with the same name, but with the ".withOperators" extension.

Example Input/Output:

Input:

local variable = 100
variable += 5
variable -= 5
variable *= 5
variable /= 5
variable %= 5
variable &= 5
variable ^= 5
variable |= 5
variable >>= 5
variable <<= 5
variable += 125 * 100 - 2623 - 930
print(variable)

Output:

local variable = 100
variable = variable + 5
variable = variable - 5
variable = variable * 5
variable = variable / 5
variable = variable % 5
variable = bit.band(variable, 5)
variable = bit.bxor(variable, 5)
variable = bit.bor(variable, 5)
variable = bit.brshift(variable, 5)
variable = bit.blshift(variable, 5)
variable = variable + 125*100-2623-930
print(variable)

Download:
Operator Replacer on Pastebin

In-game Download:

pastebin get FuTrBPMq operatorReplacer
Cruor #2
Posted 24 November 2012 - 12:55 PM
Moved as requested.