Parser.cs :  » Development » devAdvantage » AnticipatingMinds » Genesis » CodeParser » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » devAdvantage 
devAdvantage » AnticipatingMinds » Genesis » CodeParser » Parser.cs
using System;
using System.Reflection;
using System.Diagnostics;
using System.Text;
using System.IO;
using AnticipatingMinds.Genesis.CodeDOM;
using AnticipatingMinds.Genesis.CodeDOM.Utilities;
using System.Collections.Specialized;
using System.Threading;
using System.CodeDom.Compiler;
using System.Collections;
using System.Security.Permissions;

//Add threading and meat formultithreading. Background/foreground parsing.
//Leave only events and one function that actually does parse.
namespace AnticipatingMinds.Genesis.CodeParser{
  public class ParsingErrorEventArgs : EventArgs
  {
    public ParsingErrorEventArgs(CompilerError erorr)
    {
      this.parserError = erorr;
    }

    public CompilerError Error
    {
      get
      {
        return parserError;
      }
    }

    private CompilerError parserError;
  }
  public delegate void ParsingErrorEventHandler(object sender, ParsingErrorEventArgs e);

  public class ParsingProgressEventArgs : EventArgs
  {
    public ParsingProgressEventArgs(byte percentsCompleted)
    {
      this.percentsCompleted = percentsCompleted;
    }

    public byte PercentsCompleted
    {
      get
      {
        return percentsCompleted;
      }
    }

    private byte percentsCompleted = 0;
  }
  public delegate void ParsingProgressEventHandler(object sender, ParsingProgressEventArgs e);

  public class ParsingStartedEventArgs : EventArgs
  {
    public ParsingStartedEventArgs(string fileName)
    {
      this.fileName = fileName;
    }

    public string FileName
    {
      get
      {
        return fileName;
      }
    }

    private string fileName;
  }
  public delegate void ParsingStartedEventHandler(object sender, ParsingStartedEventArgs e);

  public class ParsingEndedEventArgs : EventArgs
  {
    public ParsingEndedEventArgs(CodeCompileUnit compiledCodeGraph,CompilerErrorCollection parsingErrors)
    {
      this.compiledCodeGraph = compiledCodeGraph;
      this.parsingErrors = parsingErrors;
    }

    public CodeCompileUnit CompiledCodeGraph
    {
      get
      {
        return compiledCodeGraph;
      }
    }

    public CompilerErrorCollection Errors
    {
      get
      {
        return parsingErrors;
      }
    }

    private CodeCompileUnit compiledCodeGraph;
    private CompilerErrorCollection parsingErrors;
  }

  public delegate void ParsingEndedEventHandler(object sender, ParsingEndedEventArgs e);
  [System.Security.Permissions.StrongNameIdentityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand,
     PublicKey=
     "00240000048000009400000006020000002400005253413100040000010001009D309779C258129573FC313836474C75C4CE9F4" +
     "107524FA0B9A6DB2E52754459C5A8946E4CBD5B98ACDB2413C5AFD38C1DF00C9A946713E867237B47F9D9CC473D4A853EACBEAB" + 
     "799EC0A271B468D4B6D52301A414A7772F05FEBD2BA7D0A2835F0D45E401C3C37F9E7B991D29F07DA88E20BB3839A34A2739AB6" + 
     "56B5204C8BC")]
  public abstract class CodeParser
  {
    protected CodeParser(string sourceCode,string fileName,CodeAssembly codeAssembly)
    {
      this.sourceCode = sourceCode;
      this.fileName = fileName;
      this.codeAssembly = codeAssembly;
    }

    public virtual event ParsingErrorEventHandler ParsingError;
    public virtual event ParsingProgressEventHandler ParsingProgress;
    public virtual event ParsingStartedEventHandler ParsingStarted;
    public virtual event ParsingEndedEventHandler ParsingEnded;
    
    public abstract CodeAssemblyFile Parse(ManualResetEvent cancelEvent);


    protected void OnParsingError(CompilerError error)
    {
      if(ParsingError != null)
        ParsingError(this,new ParsingErrorEventArgs(error));
    }
    protected void OnParsingProgress(byte percentsCompleted)
    {
      if(ParsingProgress != null)
        ParsingProgress(this,new ParsingProgressEventArgs(percentsCompleted));
    }
    protected void OnParsingStarted(string fileName)
    {
      if(ParsingStarted != null)
        ParsingStarted(this,new ParsingStartedEventArgs(fileName));
    }

    protected void OnParsingEnded(CodeCompileUnit compiledCodeGraph,CompilerErrorCollection parsingErrors)
    {
      if(ParsingEnded != null)
        ParsingEnded(this,new ParsingEndedEventArgs(compiledCodeGraph,parsingErrors));
    }

    public abstract CompilerErrorCollection Errors
    {
      get;
    }

    public string SourceCode
    {
      get
      {
        return sourceCode;
      }
    }

    public string FileName
    {
      get
      {
        return fileName;
      }
    }

    public CodeAssembly CodeAssembly
    {
      get
      {
        return codeAssembly;
      }
    }

    private static string[] emptyStringArray = new string[0];
    private string sourceCode;
    private string fileName;
    private CodeAssembly codeAssembly;
  };
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.