Beispiel #1
0
        private void GenerateMicrolexCode(CompilationUnit cu, CompilerDTO dto, ProgramPart part)
        {
            var visitor = new PsiCodeGeneratorVisitor(cu, dto);

            try
            {
                switch (part)
                {
                    case ProgramPart.CompilationUnit:
                        visitor.Visit(cu.PsiNodeSyntaxTree as CompilationUnitNode);
                        break;
                    case ProgramPart.Statement:
                        var node = new StatementNode();
                        node.Init();
                        node.Type = NodeType.Statement;

                        node.Add(cu.PsiNodeSyntaxTree);
                        visitor.Visit(node);
                        break;
                    default:
                        visitor.Visit(cu.PsiNodeSyntaxTree as CompilationUnitNode);
                        break;
                }

                //visitor.CurrentCompilationUnit.PsiNodeSyntaxTree = result.PsiNode as CompilationUnitNode;

            }
            catch (Exception e)
            {
                dto.CompilerMessages.Errors.Add(new Error
                {
                    MessageText = e.ToString(),
                    Interval = new Interval { FileName = cu.FileName }
                });
            }
        }
Beispiel #2
0
 private void Analise(CompilationUnit cu, CompilerDTO dto, ProgramPart part)
 {
     if (part == ProgramPart.CompilationUnit)
         new PsiSemanticAnaliserVisitor(cu, dto).Visit(cu.PsiNodeSyntaxTree as CompilationUnitNode);
     //else What To Do ?
 }