/* =====================================
 * Generated by Mod-c 0.26.5
 * HEADER statement MODULE
 * ===================================== */

#ifndef MODC_MODULE_statement_H
#define MODC_MODULE_statement_H

#include <stdint.h>
#include <stdbool.h>
#include <assert.h>

#define nil ((void *)0)
#define NIL nil
typedef uint8_t byte;
typedef const char* string;
typedef int integer;
typedef unsigned int cardinal;
typedef float real;

/**
 * Mod-c
 * By M. Scott Reynolds
 * Date 17 July 2026
 *
 * statement.mc - Statement parsing routines.
 */

/* === IMPORT === */
#include "arena.h"

/* === IMPORT === */
#include "utils.h"

/* === IMPORT === */
#include "node.h"

/* === IMPORT === */
#include "parser_common.h"

/* === IMPORT === */
#include "parser_main.h"

/* === IMPORT === */
#include "Lexer.h"

/* === IMPORT === */
#include "stddef.h"

/* === IMPORT === */
#include "stdlib.h"

/* === IMPORT === */
#include "stdio.h"

/* === TYPE EXPORT === */
typedef Node* pNode;

/**
 * Parse DEFER statement.
 * Grammar: "DEFER" statement ;
 * The deferred statement is stored in the currenb block's defer list.
 */

/* === PROC/FUNC EXPORT === */
pNode parse_defer_stmt(pParser p);

/**
 * Parse DEBUG statement.
 * Grammar: "DEBUG" statement ;
 * The debug statement is generated in code when a debug flag is set.
 */

/* === PROC/FUNC EXPORT === */
pNode parse_debug_stmt(pParser p);

/**
 * Parse SWITCH statement.
 * Grammar:
 * 	"SWITCH" expression "OF"
 * 		{ "CASE" case-labels ":" statement-sequence }
 *		"ELSE" ":" statement-sequence
 * 	"END" ;
 *
 * 	case-labels = const-expression { "," const-expression } ;
 *
 * No fallthrough. ELSE is required.
 */

/* === PROC/FUNC EXPORT === */
Node* parse_switch_stmt(pParser p);

/**
 * Parse qualident = identifier { "." identifier } starting at current IDENT.
 * Returns false if current token is not TOK_IDENT.
 */

/**
 * Parse IMPORT statement
 * Grammar:
 * 		IMPORT [ import-item { , import-item } ] FROM import-source;
 *		import-source = string-literal | qualident ;
 * 		import-item = (identifier { "," identifier } | type-identifier "::" identifier) [ AS identifier ] ;
 *
 * Returns NODE_IMPORT node or nil if no IMPORT seen.
 */

/* === PROC/FUNC EXPORT === */
Node* parse_import_stmt(pParser p);

/**
 * Parse one import item:
 * 		plain: ident { "." ident } [ AS ident ]
 * 		method: Type "::" name [ AS ident ]
 */

/* === PROC/FUNC EXPORT === */
Node* parse_import_item(pParser p);

/**
 * Parse break statement
 */

/* === PROC/FUNC EXPORT === */
Node* parse_break_stmt(pParser p);

/**
 * Parse CONTINUE statement
 */

/* === PROC/FUNC EXPORT === */
Node* parse_continue_stmt(pParser p);

/**
 * Parse RETURN statement
 */

/* === PROC/FUNC EXPORT === */
Node* parse_return_stmt(pParser p);

/**
 * Parse IF statement
 */

/* === PROC/FUNC EXPORT === */
Node* parse_if_stmt(pParser p);

/**
 * Parse WHILE ... DO ... END statement
 * Grammar:
 * 		"WHILE" expression "DO" statement-sequence "END"
 *
 * Returns NODE_WHILE node
 * Exits on fatal error (missing DO, END, etc).
 */

/* === PROC/FUNC EXPORT === */
Node* parse_while_stmt(pParser p);

/**
 * Parse FOR statement with optional BY step
 * Grammar:
 *		"FOR" identifier ":=" expression ( "TO" | "DOWNTO" ) expression
 *			[ "BY" const-expression ] "DO" statement-sequence "END"
 */

/* === PROC/FUNC EXPORT === */
Node* parse_for_stmt(pParser p);

/**
 * Parse REPEAT ... UNTIL statement
 */

/* === PROC/FUNC EXPORT === */
Node* parse_repeat_until_stmt(pParser p);

/**
 * Parse LOOP statement
 */

/* === PROC/FUNC EXPORT === */
Node* parse_loop_stmt(pParser p);

/**
 * Parse INC / DEC statement
 * Grammar:
 * 		inc-stmt = "INC" "(" designator [ "," expression ] ")"
 * 		dec-stmt = "DEC" "(" designator [ "," expression ] ")"
 */

/* === PROC/FUNC EXPORT === */
Node* parse_inc_dec_stmt(pParser p);

void statement(void);

#endif /* MODC_MODULE_statement_H */
