<commit_before>#include "AtomicStatementNode.h"
#include "../../Parser.h"
#include "AtomicExpressionNode.h"

#include <assert.h>

namespace Language {
    ASTNode* AtomicStatementNode::parse(Parser& parser) {
        std::string type;

        AtomicStatementNode* node = new AtomicStatementNode();

        assert(parser.next().type() == Token::Type::KeywordAtomic);

        if (parser.nextIf(":")) {
            type = parser.next().str();
        } else {
            type = "ordered";
        }

        if (parser.peek().type() == Token::Type::PunctuationOpenParen) {
            assert(type != "strict");
            return AtomicExpressionNode::parse(parser, type);
        }

        parser.parseNewline(true);

        while (true) {
            if (parser.peek().type() == Token::Type::KeywordEnd) {
                parser.next();
                break;
            }

            if (parser.peek().type() == Token::Type::KeywordElse) {
                node->_elseNode = ElseNode::parse(parser);
                break;
            }

            node->addChild(parser.parseStatement());
        }

        return node;
    }

    std::string AtomicStatementNode::name() const {
        return "AtomicStatement";
    }

    bool AtomicStatementNode::strict() const {
        return _strict;
    }

    void AtomicStatementNode::codeGenCSource(CSourceContext& context) {
        context << "if (three_begin_transaction(";
        context << (this->strict() ? "true" : "false");
        context.current()->printLineAndIndent(")) {");

        this->codeGenCSourceForChildren(context);

        context.current()->printLine("three_end_transaction();");

        if (this->_elseNode) {
            context.current()->decreaseIndentation();
            context.current()->printLineAndIndent("} else {");
            this->_elseNode->codeGenCSourceForChildren(context);
        }

        context.current()->outdentAndPrintLine("}");
    }
}<commit_msg>Corrected a small issue with strict atomic statements<commit_after>#include "AtomicStatementNode.h"
#include "../../Parser.h"
#include "AtomicExpressionNode.h"

#include <assert.h>

namespace Language {
    ASTNode* AtomicStatementNode::parse(Parser& parser) {
        std::string type;

        AtomicStatementNode* node = new AtomicStatementNode();

        assert(parser.next().type() == Token::Type::KeywordAtomic);

        if (parser.nextIf(":")) {
            type = parser.next().str();
        } else {
            type = "ordered";
        }

        node->_strict = type == "strict";

        if (parser.peek().type() == Token::Type::PunctuationOpenParen) {
            assert(type != "strict");
            return AtomicExpressionNode::parse(parser, type);
        }

        parser.parseNewline(true);

        while (true) {
            if (parser.peek().type() == Token::Type::KeywordEnd) {
                parser.next();
                break;
            }

            if (parser.peek().type() == Token::Type::KeywordElse) {
                node->_elseNode = ElseNode::parse(parser);
                break;
            }

            node->addChild(parser.parseStatement());
        }

        return node;
    }

    std::string AtomicStatementNode::name() const {
        return "AtomicStatement";
    }

    bool AtomicStatementNode::strict() const {
        return _strict;
    }

    void AtomicStatementNode::codeGenCSource(CSourceContext& context) {
        context << "if (three_begin_transaction(";
        context << (this->strict() ? "true" : "false");
        context.current()->printLineAndIndent(")) {");

        this->codeGenCSourceForChildren(context);

        context << "three_end_transaction(";
        context << (this->strict() ? "true" : "false");
        context.current()->printLine(");");

        if (this->_elseNode) {
            context.current()->decreaseIndentation();
            context.current()->printLineAndIndent("} else {");
            this->_elseNode->codeGenCSourceForChildren(context);
        }

        context.current()->outdentAndPrintLine("}");
    }
}
{'fraction_non_alphanumeric': 0.1521099116781158, 'fraction_numerical': 0.0, 'mean_word_length': 2.282608695652174, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2969411', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1092, 'n_words': 182}