/// <summary>Generates code</summary> /// <param name="tree">Root of a syntax tree</param> /// <param name="table">Table of symbols</param> /// <param name="columns">Columns layout</param> public void Generate(TypeCobol.Compiler.Nodes.Root tree, TypeCobol.Compiler.CodeModel.SymbolTable table, TypeCobol.Compiler.Text.ColumnsLayout columns = TypeCobol.Compiler.Text.ColumnsLayout.FreeTextFormat) { // STEP 0: Initialize the global values. RootNode = tree; SymTable = table; Layout = columns; //Create the Initial target document. CreateTargetDocument(); // STEP 1: modify tree to adapt it to destination language // 1.1 Run the Qualifier action on this node Qualifier qualifier = new Qualifier(this, tree); qualifier.Execute(); // 1.2 Perform other actions Actions.Perform(tree); // STEP 2: convert tree to destination language code TreeToCode(); }
/// <summary> /// Use a pre-existing text document, already initialized from a Cobol file /// </summary> public FileCompiler(string libraryName, string fileName, SourceFileProvider sourceFileProvider, IProcessedTokensDocumentProvider documentProvider, ColumnsLayout columnsLayout, TypeCobolOptions compilerOptions, CodeModel.SymbolTable customSymbols, bool isCopyFile, MultilineScanState scanState, CompilationProject compilationProject, List <RemarksDirective.TextNameVariation> copyTextNameVariations) : this(libraryName, fileName, null, sourceFileProvider, documentProvider, columnsLayout, null, compilerOptions, customSymbols, isCopyFile, scanState, compilationProject, copyTextNameVariations) { }
/// <summary> /// Load a Cobol source file in memory /// </summary> public FileCompiler(string libraryName, string fileName, SourceFileProvider sourceFileProvider, IProcessedTokensDocumentProvider documentProvider, ColumnsLayout columnsLayout, TypeCobolOptions compilerOptions, CodeModel.SymbolTable customSymbols, bool isCopyFile, CompilationProject compilationProject) : this(libraryName, fileName, null, sourceFileProvider, documentProvider, columnsLayout, null, compilerOptions, customSymbols, isCopyFile, null, compilationProject, null) { }
private IDictionary <string, List <Program> > GetProgramsTable(SymbolTable symbolTable) { return(symbolTable.Programs); }
private IDictionary <string, List <FunctionDeclaration> > GetFunctionTable(SymbolTable symbolTable) { return(symbolTable.Functions); }
private IDictionary <string, List <TypeDefinition> > GetTypeTable(SymbolTable symbolTable) { return(symbolTable.Types); }
private IDictionary <string, List <Paragraph> > GetParagraphTable(SymbolTable symbolTable) { return(symbolTable.Paragraphs); }
private IDictionary <string, List <Section> > GetSectionTable(SymbolTable symbolTable) { return(symbolTable.Sections); }
private List <T> GetFromTableAndEnclosing <T>(string head, Func <SymbolTable, IDictionary <string, List <T> > > getTableFunction, SymbolTable symbolTable = null) where T : Node { symbolTable = symbolTable ?? this; var table = getTableFunction.Invoke(symbolTable); var values = GetFromTable(head, table); if (EnclosingScope != null) { values.AddRange(EnclosingScope.GetFromTableAndEnclosing(head, getTableFunction)); } return(values); }
private IDictionary <string, List <DataDefinition> > GetDataDefinitionTable(SymbolTable symbolTable) { return(symbolTable.DataEntries); }
public SourceProgram(SymbolTable EnclosingScope, CodeElement codeElement) : base(codeElement) { IsNested = false; SymbolTable = new SymbolTable(EnclosingScope); SyntaxTree.Root.SymbolTable = SymbolTable; }