Exemple #1
0
 internal LanguageCodeLocation(ISourceCodeUnit codeUnit, int charNum, int lineNum, int colNum, int spanLength)
 {
     CodeUnit        = codeUnit;
     CharacterNumber = charNum;
     LineNumber      = lineNum;
     ColumnNumber    = colNum;
     SpanLength      = spanLength;
 }
 protected LanguageProjectCodeUnitCompiler(LanguageProjectCompiler parentCompiler, ISourceCodeUnit codeUnit, ParseTreeNode rootParseNode)
 {
     ParentCompiler    = parentCompiler;
     CodeUnit          = codeUnit;
     RootParseNode     = rootParseNode;
     RootAst           = parentCompiler.RootAst;
     CompilationLog    = parentCompiler.CompilationLog;
     TranslatorContext = parentCompiler.TranslatorContext;
 }
Exemple #3
0
        private bool ChangeOpenedSourceFile(ISourceCodeUnit sourceCodeUnit)
        {
            //A project must be active
            if (_dslProject == null)
            {
                return(false);
            }

            //If the opened file is the same as the new file do nothing
            if (ReferenceEquals(sourceCodeUnit, _openedDslFile))
            {
                return(true);
            }

            //If the opened file nedds saving ask for it
            if (AskSaveSourceCode() == false)
            {
                return(false);
            }

            //Set the opened file to the new file
            _openedDslFile = sourceCodeUnit;

            if (!ReferenceEquals(_openedDslFile, null))
            {
                //Load the code into the text editor
                if (ShowSourceCode() == false)
                {
                    return(false);
                }

                //Update the selected item in the source files list if necessary
                if (((ISourceCodeUnit)listBoxSourceFiles.SelectedItem) != sourceCodeUnit)
                {
                    for (var i = 0; i < listBoxSourceFiles.Items.Count; i++)
                    {
                        if ((ISourceCodeUnit)listBoxSourceFiles.Items[i] == _openedDslFile)
                        {
                            listBoxSourceFiles.SelectedIndex = i;
                            break;
                        }
                    }
                }
            }
            else
            {
                SourceCodeTextEditor.Text = "";

                SetEditorTextChangedStatus(false);
            }

            UpdateInterface_EnableControls();

            return(true);
        }
Exemple #4
0
 public override ParseTreeNode ParseCodeUnit(ISourceCodeUnit codeUnit)
 {
     try
     {
         return(GMacSourceParser.ParseAst(codeUnit.CodeText, CompilationLog));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #5
0
 protected override LanguageProjectCodeUnitCompiler InitializeCodeUnitCompiler(ISourceCodeUnit codeUnit, ParseTreeNode rootParseNode)
 {
     return(new GMacProjectCodeUnitCompiler(this, codeUnit, rootParseNode));
 }
 internal GMacProjectCodeUnitCompiler(GMacProjectCompiler parentCompiler, ISourceCodeUnit codeUnit, ParseTreeNode rootParseNode)
     : base(parentCompiler, codeUnit, rootParseNode)
 {
 }
 /// <summary>
 /// Parse the source code to generate the parse tree for the given code unit
 /// </summary>
 public abstract ParseTreeNode ParseCodeUnit(ISourceCodeUnit codeUnit);
 /// <summary>
 /// Create a child code unit compiler
 /// </summary>
 /// <param name="codeUnit"></param>
 /// <returns></returns>
 protected LanguageProjectCodeUnitCompiler InitializeCodeUnitCompiler(ISourceCodeUnit codeUnit)
 {
     return(InitializeCodeUnitCompiler(codeUnit, null));
 }
 /// <summary>
 /// Create a child code unit compiler
 /// </summary>
 /// <param name="codeUnit"></param>
 /// <param name="rootParseNode"></param>
 /// <returns></returns>
 protected abstract LanguageProjectCodeUnitCompiler InitializeCodeUnitCompiler(ISourceCodeUnit codeUnit, ParseTreeNode rootParseNode);