UNPKG

python2igcse

Version:

Convert Python code to IGCSE Pseudocode format

133 lines 3.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParserFactory = void 0; exports.createParser = createParser; exports.createPreconfiguredParser = createPreconfiguredParser; exports.getParserCapabilities = getParserCapabilities; exports.getParserBenchmark = getParserBenchmark; // Parser factory const python_parser_1 = require("./python-parser"); /** * Parser factory class */ class ParserFactory { /** * Create a parser */ static create(config) { switch (config.type) { case 'python': return new python_parser_1.PythonParser(config.options); case 'javascript': case 'java': case 'cpp': throw new Error(`Parser for ${config.type} is not implemented yet`); default: throw new Error(`Unknown parser type: ${config.type}`); } } /** * Get list of supported parsers */ static getSupportedParsers() { return ['python']; } /** * Check if parser is supported */ static isSupported(type) { return this.getSupportedParsers().includes(type); } } exports.ParserFactory = ParserFactory; /** * Convenience function: Create Python parser */ function createParser(options) { return ParserFactory.create({ type: 'python', options: options || {} }); } /** * Convenience function: Create preconfigured parser */ function createPreconfiguredParser(preset) { const presets = { strict: { strictTypes: true, preserveComments: true, debug: false, maxDepth: 20 }, lenient: { strictTypes: false, preserveComments: true, debug: false, maxDepth: 50 }, debug: { strictTypes: true, preserveComments: true, debug: true, maxDepth: 30 } }; return createParser(presets[preset]); } /** * Get parser capabilities */ function getParserCapabilities(type) { switch (type) { case 'python': return { supportedFeatures: [ 'Variables and assignments', 'Control structures (if/else, for, while)', 'Functions and procedures', 'Basic data types', 'Arrays and lists', 'Comments', 'Input/Output operations', 'Arithmetic and logical operations' ], limitations: [ 'Complex object-oriented features', 'Advanced Python-specific syntax', 'Decorators and metaclasses', 'Async/await patterns', 'Complex comprehensions' ], recommendedUse: 'Basic to intermediate Python programs suitable for educational purposes' }; default: return { supportedFeatures: [], limitations: ['Not implemented'], recommendedUse: 'Not available' }; } } /** * Get parser benchmark information */ function getParserBenchmark(type) { switch (type) { case 'python': return { type: 'python', avgParseTimePerLine: 0.5, memoryUsagePer1000Lines: 2.0, maxRecommendedLines: 10000 }; default: return { type, avgParseTimePerLine: 0, memoryUsagePer1000Lines: 0, maxRecommendedLines: 0 }; } } //# sourceMappingURL=factory.js.map