java2ib
Version:
TypeScript library that converts Java code into IB Computer Science pseudocode format
117 lines • 4.91 kB
JavaScript
"use strict";
/**
* Type definitions for the Java to IB Pseudocode Converter
*
* This module contains all the TypeScript interfaces, types, and enums used
* throughout the converter library. These types provide strong typing for
* the conversion process and ensure type safety when using the library.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeType = exports.TokenType = exports.ErrorSeverity = exports.ErrorType = void 0;
/**
* Categories of errors that can occur during conversion.
*
* These types help classify errors by the stage of processing
* where they occurred, making debugging easier.
*/
var ErrorType;
(function (ErrorType) {
/** Errors in tokenizing the source code (invalid characters, etc.) */
ErrorType["LEXICAL_ERROR"] = "lexical";
/** Errors in parsing tokens into an abstract syntax tree */
ErrorType["SYNTAX_ERROR"] = "syntax";
/** Errors in semantic analysis (undefined variables, type mismatches) */
ErrorType["SEMANTIC_ERROR"] = "semantic";
/** Errors in the conversion process itself */
ErrorType["CONVERSION_ERROR"] = "conversion";
})(ErrorType || (exports.ErrorType = ErrorType = {}));
/**
* Severity levels for errors and warnings.
*
* Determines how critical an issue is and whether it prevents
* successful conversion.
*/
var ErrorSeverity;
(function (ErrorSeverity) {
/** Critical errors that prevent successful conversion */
ErrorSeverity["ERROR"] = "error";
/** Non-critical issues that may require attention */
ErrorSeverity["WARNING"] = "warning";
/** Informational messages about the conversion process */
ErrorSeverity["INFO"] = "info";
})(ErrorSeverity || (exports.ErrorSeverity = ErrorSeverity = {}));
/**
* Categories of tokens recognized by the lexer.
*
* These types classify different kinds of tokens found in Java source code
* during the lexical analysis phase.
*/
var TokenType;
(function (TokenType) {
/** Java keywords like 'if', 'while', 'public', 'class', etc. */
TokenType["KEYWORD"] = "keyword";
/** Variable names, method names, class names, etc. */
TokenType["IDENTIFIER"] = "identifier";
/** String literals, numeric literals, boolean literals, etc. */
TokenType["LITERAL"] = "literal";
/** Operators like '+', '-', '==', '&&', etc. */
TokenType["OPERATOR"] = "operator";
/** Punctuation marks like '{', '}', '(', ')', ';', etc. */
TokenType["PUNCTUATION"] = "punctuation";
/** Whitespace characters (spaces, tabs, newlines) */
TokenType["WHITESPACE"] = "whitespace";
/** Single-line and multi-line comments */
TokenType["COMMENT"] = "comment";
})(TokenType || (exports.TokenType = TokenType = {}));
/**
* Types of AST nodes that can be created during parsing.
*
* These node types represent different Java language constructs
* that the parser can recognize and convert to pseudocode.
*/
var NodeType;
(function (NodeType) {
/** Root node representing the entire program */
NodeType["PROGRAM"] = "Program";
/** Java class declaration */
NodeType["CLASS_DECLARATION"] = "ClassDeclaration";
/** Method or function declaration */
NodeType["METHOD_DECLARATION"] = "MethodDeclaration";
/** Variable declaration statement */
NodeType["VARIABLE_DECLARATION"] = "VariableDeclaration";
/** If-else conditional statement */
NodeType["IF_STATEMENT"] = "IfStatement";
/** While loop statement */
NodeType["WHILE_LOOP"] = "WhileLoop";
/** For loop statement */
NodeType["FOR_LOOP"] = "ForLoop";
/** Variable assignment statement */
NodeType["ASSIGNMENT"] = "Assignment";
/** Binary expression (operations with two operands) */
NodeType["BINARY_EXPRESSION"] = "BinaryExpression";
/** Method or function call */
NodeType["METHOD_CALL"] = "MethodCall";
/** Array element access */
NodeType["ARRAY_ACCESS"] = "ArrayAccess";
/** Literal values (numbers, strings, booleans) */
NodeType["LITERAL"] = "Literal";
/** Variable or method identifiers */
NodeType["IDENTIFIER"] = "Identifier";
/** Return statement in methods */
NodeType["RETURN_STATEMENT"] = "ReturnStatement";
/** Switch statement */
NodeType["SWITCH_STATEMENT"] = "SwitchStatement";
/** Case clause in switch statement */
NodeType["CASE_CLAUSE"] = "CaseClause";
/** Default clause in switch statement */
NodeType["DEFAULT_CLAUSE"] = "DefaultClause";
/** Break statement */
NodeType["BREAK_STATEMENT"] = "BreakStatement";
/** Continue statement */
NodeType["CONTINUE_STATEMENT"] = "ContinueStatement";
/** Enhanced for loop (for-each) */
NodeType["ENHANCED_FOR_LOOP"] = "EnhancedForLoop";
/** Array initialization expression */
NodeType["ARRAY_INITIALIZATION"] = "ArrayInitialization";
})(NodeType || (exports.NodeType = NodeType = {}));
//# sourceMappingURL=types.js.map