UNPKG

python2igcse

Version:

Convert Python code to IGCSE Pseudocode format

112 lines 2.76 kB
import { IR, IRKind, IRMeta } from '../types/ir'; import { BaseParser } from './base-parser'; /** * Basic interface for Python AST nodes */ interface ASTNode { type: string; lineno?: number; col_offset?: number; inlineComment?: string; [key: string]: any; } /** * Visitor for converting Python AST to IR */ export declare class PythonASTVisitor extends BaseParser { private statementVisitor; private definitionVisitor; constructor(); /** * Main parse function */ parse(source: string): import('../types/parser').ParseResult; /** * Simple AST parser (uses external library in actual implementation) */ private parseToAST; /** * Parse statements and their child blocks */ private parseStatement; /** * Convert single line to AST node */ private parseLineToASTNode; /** * Parse augmented assignment statements */ private parseAugAssignStatement; /** * Get type of augmented assignment operator */ private getAugAssignOpType; private parseIfStatement; private parseForStatement; private parseWhileStatement; private parseAssignStatement; /** * Parse expressions and convert to AST nodes */ private parseExpression; /** * Parse simple expressions (variables, literals) */ private parseSimpleExpression; /** * Get AST node for comparison operators */ private getCompareOpNode; /** * Get AST node for arithmetic operators */ private getArithOpNode; private parsePrintStatement; /** * Convert AST nodes to IR */ visitNode(node: ASTNode): IR; private visitModule; /** * Parse function definitions */ private parseFunctionDef; /** * Parse argument lists */ private parseArguments; /** * Split arguments considering parentheses balance */ private splitArgumentsRespectingParentheses; /** * Parse parameter lists */ private parseParameters; /** * Parse return statements */ private parseReturnStatement; /** * Parse class definitions */ private parseClassDef; /** * Register class definitions in context */ private registerClassDefinition; /** * Pre-register all class definitions (first pass of 2-pass processing) */ private preRegisterAllClasses; /** * Helper for creating IR nodes */ protected createIRNode(kind: IRKind, text: string, children?: IR[], meta?: IRMeta): IR; /** * Create parse results */ protected createParseResult(ir: IR[]): import('../types/parser').ParseResult; } export {}; //# sourceMappingURL=visitor.d.ts.map