I want to add "readonly" keyword to my pypp:

const fs = require('fs');
const { spawn } = require('child_process');

const config = 'CONFIG';
let mainName = 'app.pypp';

if (fs.existsSync(config)) {
    fs.readFile(config, 'utf8', (err, data) => {
        if (err) throw err;
        const match = data.match(/APP_NAME=(.+)\.pypp/);
        if (match) {
            mainName = match[1] + '.pypp';
        } else {
            formatError(`Couldn't find the main file name in the config file.`);
        }

        if (fs.existsSync(mainName)) {
            translate(mainName);
        } else {
            formatError(`Couldn't find the file '${mainName}' in directory.`);
        }
    });
} else {
    if (fs.existsSync(mainName)) {
        translate(mainName);
    } else {
        formatError(`Couldn't find the file '${mainName}' in directory.`);
    }
}

function formatError(error, color = '\x1b[31m') {
    console.error(`${color}ERROR: ${error}\x1b[37m`);
}

function translate(fileName) {
    fs.readFile(fileName, 'utf8', (err, data) => {
        if (err) throw err;

        const formattedData = processCode(data);

        fs.writeFile('app.py', formattedData, err => {
            if (err) throw err;

            const pythonProcess = spawn('python', ['app.py'], { stdio: 'inherit' });

            pythonProcess.on('close', () => {
                fs.unlink('app.py', err => {
                    if (err) throw err;
                });
            });
        });
    });
}

function processCode(code) {
    let functionCounter = 0;
    let output = '';
    let functionsCode = '';
    let i = 0;

    while (i < code.length) {
        // Skip whitespace and accumulate it
        let whitespace = '';
        while (i < code.length && /\s/.test(code[i])) {
            whitespace += code[i++];
        }
        output += whitespace;

        // Check for 'def' keyword
        if (code.startsWith('def', i) && (/\s|\(/.test(code[i + 3] || ''))) {
            let j = i + 3;
            // Skip any whitespace after 'def'
            while (j < code.length && /\s/.test(code[j])) j++;

            if (code[j] === '(') {
                // Anonymous function
                let { funcCode, funcName, newIndex } = extractAnonymousFunction(code, i, functionCounter++);
                functionsCode += funcCode + '\n';
                i = newIndex;
                output += funcName;
            } else if (/[a-zA-Z_]/.test(code[j])) {
                // Regular function
                let { funcCode, newIndex } = extractRegularFunction(code, i);
                output += funcCode;
                i = newIndex;
            } else {
                formatError('Invalid function definition after def');
                return '';
            }
        } else {
            output += code[i++];
        }
    }

    // Combine the function definitions and the rest of the code
    const finalOutput = functionsCode + output;

    return replaceCurlyBrackets(finalOutput);
}

function extractAnonymousFunction(code, i, functionCounter) {
    let funcName = `__anonymous_function_${functionCounter}`;
    let funcCode = '';
    let j = i; // Position in the code

    // Skip 'def'
    j += 3;

    // Skip whitespace
    while (j < code.length && /\s/.test(code[j])) j++;

    // Expect '()'
    if (code[j] === '(' && code[j + 1] === ')') {
        j += 2; // Skip '()'
    } else {
        formatError('Expected "()" after "def" in anonymous function definition');
        return {
            funcCode: '',
            funcName: '',
            newIndex: code.length
        };
    }

    // Skip whitespace
    while (j < code.length && /\s/.test(code[j])) j++;

    // Expect '{'
    if (code[j] !== '{') {
        formatError('Expected "{" after anonymous function definition');
        return {
            funcCode: '',
            funcName: '',
            newIndex: code.length
        };
    }
    j++; // Skip '{'

    // Extract function body
    let braceDepth = 1;
    let bodyStart = j;

    while (j < code.length && braceDepth > 0) {
        if (code[j] === '{') {
            braceDepth++;
        } else if (code[j] === '}') {
            braceDepth--;
        }
        j++;
    }

    if (braceDepth !== 0) {
        formatError('Unmatched braces in anonymous function');
        return {
            funcCode: '',
            funcName: '',
            newIndex: code.length
        };
    }

    let bodyEnd = j - 1;
    let funcBody = code.slice(bodyStart, bodyEnd);

    // Indent the function body
    let funcBodyLines = funcBody.split('\n');
    funcBodyLines = funcBodyLines.map(line => '    ' + line.trimRight());
    funcBody = funcBodyLines.join('\n');

    // Build the function code
    funcCode += `def ${funcName}():\n${funcBody}`;

    // Return the function code and the new index
    return {
        funcCode,
        funcName,
        newIndex: j
    };
}

function extractRegularFunction(code, i) {
    let j = i; // Position in the code
    let funcDef = '';

    // Build the function definition

    // Skip 'def'
    funcDef += code.substr(j, 3); // 'def'
    j += 3;

    // Accumulate until the opening brace '{'
    while (j < code.length && code[j] !== '{') {
        funcDef += code[j];
        j++;
    }

    if (j >= code.length) {
        formatError('Expected "{" after function declaration');
        return '';
    }

    // Include the '{'
    funcDef += code[j];
    j++;

    // Now find the matching closing brace '}'
    let braceDepth = 1;
    while (j < code.length && braceDepth > 0) {
        funcDef += code[j];
        if (code[j] === '{') braceDepth++;
        else if (code[j] === '}') braceDepth--;
        j++;
    }

    if (braceDepth !== 0) {
        formatError('Unmatched braces in function definition');
        return '';
    }

    return {
        funcCode: funcDef,
        newIndex: j
    };
}

function replaceCurlyBrackets(code) {
    let formattedCode = '';
    let indentLevel = 0;
    const indentSize = 4;
    let i = 0;

    // States
    let inSingleQuote = false;
    let inDoubleQuote = false;
    let inTripleSingleQuote = false;
    let inTripleDoubleQuote = false;
    let inSingleLineComment = false;
    let inMultiLineComment = false;
    let braceStack = [];

    while (i < code.length) {
        const char = code[i];
        const nextChars = code.substring(i, i + 3);

        // Handle multi-line comments start
        if (!inSingleQuote && !inDoubleQuote && !inSingleLineComment && !inMultiLineComment) {
            if (code.startsWith('/*', i)) {
                inMultiLineComment = true;
                formattedCode += '#';
                i += 2; // Skip '/*'
                continue;
            }
        }

        // Handle multi-line comments end
        if (inMultiLineComment) {
            if (code.startsWith('*/', i)) {
                inMultiLineComment = false;
                i += 2; // Skip '*/'
                continue;
            }

            if (char === '\n') {
                formattedCode += '\n#';
                i++;
            } else {
                formattedCode += char;
                i++;
            }
            continue;
        }

        // Handle string literals
        if (!inSingleQuote && !inDoubleQuote && !inTripleSingleQuote && !inTripleDoubleQuote) {
            if (nextChars === "'''") {
                inTripleSingleQuote = true;
                formattedCode += nextChars;
                i += 3;
                continue;
            } else if (nextChars === '"""') {
                inTripleDoubleQuote = true;
                formattedCode += nextChars;
                i += 3;
                continue;
            } else if (char === "'") {
                inSingleQuote = true;
                formattedCode += char;
                i++;
                continue;
            } else if (char === '"') {
                inDoubleQuote = true;
                formattedCode += char;
                i++;
                continue;
            }
        } else {
            // Inside string
            if (inTripleSingleQuote && nextChars === "'''") {
                inTripleSingleQuote = false;
                formattedCode += nextChars;
                i += 3;
                continue;
            } else if (inTripleDoubleQuote && nextChars === '"""') {
                inTripleDoubleQuote = false;
                formattedCode += nextChars;
                i += 3;
                continue;
            } else if (inSingleQuote && char === "'" && code[i - 1] !== '\\') {
                inSingleQuote = false;
                formattedCode += char;
                i++;
                continue;
            } else if (inDoubleQuote && char === '"' && code[i - 1] !== '\\') {
                inDoubleQuote = false;
                formattedCode += char;
                i++;
                continue;
            }
            formattedCode += char;
            i++;
            continue;
        }

        // Handle single-line comments
        if (!inSingleQuote && !inDoubleQuote && !inTripleSingleQuote && !inTripleDoubleQuote) {
            if (code.startsWith('//', i)) {
                // Single-line comment
                let endOfLine = code.indexOf('\n', i);
                if (endOfLine === -1) endOfLine = code.length;
                formattedCode += '#' + code.slice(i + 2, endOfLine);
                i = endOfLine;
                continue;
            }
        }

        // Skip semicolons
        if (char === ';') {
            i++;
            continue;
        }

        // Handle braces and code blocks
        if (char === '{') {
            // Determine if this is a code block or a data structure
            let isCodeBlock = false;

            // Look back to see if this is after a control statement or function definition
            let j = formattedCode.length - 1;
            while (j >= 0 && /\s/.test(formattedCode[j])) j--; // Skip whitespace

            if (j >= 0 && /[\):]/.test(formattedCode[j])) {
                isCodeBlock = true;
            } else if (j >= 0 && /[a-zA-Z0-9_]/.test(formattedCode[j])) {
                isCodeBlock = true;
            }

            if (isCodeBlock) {
                braceStack.push('block');
                formattedCode += ':';
                indentLevel++;
            } else {
                braceStack.push('data');
                formattedCode += char;
            }
            i++;
            continue;
        } else if (char === '}') {
            if (braceStack.length === 0) {
                formatError('Unmatched closing brace');
                return '';
            }
            let lastBrace = braceStack.pop();
            if (lastBrace === 'block') {
                indentLevel = Math.max(indentLevel - 1, 0);
                // Optionally add a newline here if needed
            } else {
                formattedCode += char;
            }
            i++;
            continue;
        } else if (char === '\n') {
            // Handle newlines and indentation
            formattedCode += '\n' + ' '.repeat(indentLevel * indentSize);
            i++;
            continue;
        } else {
            formattedCode += char;
            i++;
            continue;
        }
    }

    if (braceStack.length > 0) {
        formatError('Unmatched opening brace(s)');
        return '';
    }

    return formattedCode.trimEnd();
}

---

Here's how it should be used:

readonly x = 2
x = 3
print(x)

---

It should give an error and stop code execution at the line "x = 3"
Write the whole JS code all together