UNPKG

python2igcse

Version:

Convert Python code to IGCSE Pseudocode format

91 lines 2.31 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 { /** * Execute parsing (not used in DefinitionVisitor) */ parse(_source: string): ParseResult; private expressionVisitor; visitNode: ((node: ASTNode) => IR) | undefined; constructor(); /** * Set context */ setContext(context: any): void; /** * Process function definitions */ visitFunctionDef(node: ASTNode): IR; /** * Process class definitions */ visitClassDef(node: ASTNode): IR; /** * Create record type */ private createRecordType; /** * Create regular class */ private createClass; /** * Extract function parameters */ private extractParameters; /** * Convert Python type annotations to IGCSE types */ 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 a parent class by other classes */ private isUsedAsBaseClass; /** * Determine if there are return statements */ private hasReturnStatement; /** * Infer return type */ private inferReturnType; /** * Return type inference considering parameter type information */ private inferReturnTypeFromExpression; /** * Check if it's an explicit string node */ private isExplicitStringNode; protected createIRNode(kind: IRKind, text: string, children?: IR[], meta?: IRMeta): IR; /** * Capitalize the first character of a string */ private capitalizeFirstLetter; } export {}; //# sourceMappingURL=definition-visitor.d.ts.map