/** * New Command - Interactive Grammar Scaffolding * * Creates a new DSL project with paradigm-aware grammar generation */ import { Command } from 'commander'; import inquirer from 'inquirer'; import chalk from 'chalk'; import { existsSync, mkdirSync, writeFileSync } from 'fs'; import { join, dirname } from 'path'; import { fileURLToPath } from 'url'; import { inferPattern, validatePattern, generateCustomPattern } from '../utils/inference.js'; import { generateGrammar, generateGrammarFile } from '../utils/grammar-generator.js'; import { processTemplate } from '../utils/template-processor.js'; // Type definitions for our interactive flow export interface LanguageArchitecture { name: string; purpose: string; paradigm: 'functional' | 'object-oriented' | 'procedural' | 'declarative' | 'mixed'; dataPhilosophy: 'immutable' | 'mutable' | 'mixed'; } export interface LanguageFeatures { controlFlow: string[]; dataStructures: string[]; functionTypes: string[]; } export interface LanguageSyntax { comments: { type: string; pattern: string }; identifiers: { pattern: string; examples: string[] }; numbers: { pattern: string; examples: string[] }; strings: { pattern: string; examples: string[] }; variables: { keyword: string; operator: string; terminator: string; example: string }; paradigmExamples: { [key: string]: string }; } /** * Create the new command */ export function createNewCommand(): Command { const newCommand = new Command('new'); newCommand .description('Create a new DSL project') .argument('', 'Name of the DSL project') .option('-i, --interactive', 'Use interactive grammar scaffolding') .option('-t, --template