示例#1
0
        /// <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();
        }
示例#2
0
 /// <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)
 {
 }
示例#3
0
 /// <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)
 {
 }
示例#4
0
 private IDictionary <string, List <Program> > GetProgramsTable(SymbolTable symbolTable)
 {
     return(symbolTable.Programs);
 }
示例#5
0
 private IDictionary <string, List <FunctionDeclaration> > GetFunctionTable(SymbolTable symbolTable)
 {
     return(symbolTable.Functions);
 }
示例#6
0
 private IDictionary <string, List <TypeDefinition> > GetTypeTable(SymbolTable symbolTable)
 {
     return(symbolTable.Types);
 }
示例#7
0
 private IDictionary <string, List <Paragraph> > GetParagraphTable(SymbolTable symbolTable)
 {
     return(symbolTable.Paragraphs);
 }
示例#8
0
 private IDictionary <string, List <Section> > GetSectionTable(SymbolTable symbolTable)
 {
     return(symbolTable.Sections);
 }
示例#9
0
        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);
        }
示例#10
0
 private IDictionary <string, List <DataDefinition> > GetDataDefinitionTable(SymbolTable symbolTable)
 {
     return(symbolTable.DataEntries);
 }
示例#11
0
 public SourceProgram(SymbolTable EnclosingScope, CodeElement codeElement) : base(codeElement)
 {
     IsNested    = false;
     SymbolTable = new SymbolTable(EnclosingScope);
     SyntaxTree.Root.SymbolTable = SymbolTable;
 }