UNPKG

python2igcse

Version:

Convert Python code to IGCSE Pseudocode format

87 lines 2.21 kB
import { IR, IRKind, IRMeta } from '../types/ir'; import { ParseResult } from '../types/parser'; import { BaseParser } from './base-parser'; /** * Basic interface for Python AST nodes */ interface ASTNode { type: string; lineno?: number; col_offset?: number; [key: string]: any; } /** * Visitor class responsible for processing function and class definitions */ export declare class DefinitionVisitor extends BaseParser { /** * Parse execution (not used in DefinitionVisitor) */ parse(_source: string): ParseResult; private expressionVisitor; visitNode: ((node: ASTNode) => IR) | undefined; constructor(); /** * Set context */ setContext(context: any): void; /** * Process function definition */ visitFunctionDef(node: ASTNode): IR; /** * Process class definition */ visitClassDef(node: ASTNode): IR; /** * Create record type */ private createRecordType; /** * Create regular class */ private createClass; /** * Extract function parameters */ private extractParameters; /** * Convert Python type annotation to IGCSE type */ private convertPythonTypeToIGCSE; /** * Extract attributes from constructor */ private extractAttributesFromConstructor; /** * Determine whether to treat as record type */ private shouldTreatAsRecordType; /** * Determine if __init__ method is a simple constructor */ private isSimpleConstructor; /** * Check if this class is used as parent class of other classes */ private isUsedAsBaseClass; /** * Determine if there are return statements */ private hasReturnStatement; /** * Infer return type */ private inferReturnType; /** * Get operand types for operators (utilizing function call information) */ private getOperandTypeWithCallInfo; protected createIRNode(kind: IRKind, text: string, children?: IR[], meta?: IRMeta): IR; /** * Capitalize first character of string */ private capitalizeFirstLetter; } export {}; //# sourceMappingURL=definition-visitor.d.ts.map