import { OutputMerger } from "./Merging/OutputGenerator" ; import { FileMetadata } from "./Rendering/FileMetadata" ; import { Language } from "./Rendering/Languages/Language" ; import { LanguagesBag } from "./Rendering/Languages/LanguagesBag" ; import { LineResults } from "./Rendering/LineResults" ; import { RenderContext } from "./Rendering/RenderContext" ; import { BudgieFile } from "./Tokenization/BudgieFile" ; import { SourceFileParser } from "./Tokenization/Parsers/SourceFileParser" ; /**
 * Driving object to convert Budgie syntax into real language code.
 */ export class Budgie { /**
     * Backing command context for converting Budgie nodes to text.
     */ private renderContext : RenderContext ; /**
     * The current language for conversion.
     */ private language : Language ; /**
     * A lookup for known languages.
     */ private languagesBag : LanguagesBag ; /**
     * Parses lines of raw source syntax into Budgie files.
     */ private sourceFileParser : SourceFileParser ; /**
     * Generates language output by merging line results.
     */ private outputMerger : OutputMerger ; /**
     * Initializes a new instance of the Budgie class.
     */ public constructor ( language ) { this . languagesBag = new LanguagesBag ( ) ; this . sourceFileParser = new SourceFileParser ( ) ; this . setLanguage ( language ) ; } param input returns remarks public convert ( input ) { const budgieFile = this . sourceFileParser . parseLines ( input ) ; this . renderContext . setFileMetadata ( FileMetadata . defaultFileMetadata ) ; const fileLineResults = this . renderContext . convert ( budgieFile ) ; return this . outputMerger . mergeFileLineResults ( fileLineResults ) ; } returns public getLanguage ( ) { return this . language ; } param name returns public setLanguage ( name ) { this . language = this . languagesBag . getLanguageByName ( name ) ; this . renderContext = new RenderContext ( this . language ) ; this . outputMerger = new OutputMerger ( this . language . syntax . style . semicolon ) ; return this ; } }