Click here to Skip to main content
11,414,670 members (69,192 online)
Click here to Skip to main content
Add your own
alternative version

C# CodeDOM parser

, 27 Jun 2002
This is a utility which parses C# source code and creates the CODEDOM tree of the code.
cscodedomparser01.zip
CSParser
bin
Debug
Release
CodeTreeView
App.ico
bin
Debug
CodeTreeView.csproj.user
obj
Debug
temp
TempPE
cs-parser-modified.jay
cs-parser.jay
CSParser.csproj.user
CSParser.suo
jay
.cvsignore
ACKNOWLEDGEMENTS
ChangeLog
closure.o
conflict
CVS
Entries
Repository
Root
CVS
Entries
Entries.Log
Repository
Root
depend
error.o
jay.1
jay.exe
lalr.o
lr0.o
main.o
makefile
mkpar.o
NEW_FEATURES
NOTES
output.o
reader.o
README
README.jay
recover
CVS
Entries
Repository
Root
skeleton
symtab.o
verbose.o
warshall.o
NUnitTests
bin
Debug
Release
NUnitTests.csproj.user
obj
Debug
temp
TempPE
Release
temp
TempPE
TestFiles
obj
Debug
temp
TempPE
Release
temp
TempPE
testParser
bin
Debug
obj
Debug
temp
TempPE
testParser
App.ico
bin
Debug
Release
obj
Debug
temp
TempPE
Release
temp
TempPE
testParser.csproj.user
//
// GenericParser.cs: The Base Parser for the Mono compilers
//
// Author: A Rafael D Teixeira (rafaelteixeirabr@hotmail.com)
//
// Licensed under the terms of the GNU GPL
//
// Copyright (C) 2001 Ximian, Inc.
//
using System;
using System.Text;

namespace Mono.Languages
{
	using System.Collections;

	/// <summary>
	/// Base class to support multiple Jay generated parsers
	/// </summary>
	public abstract class GenericParser
	{
		protected int global_errors;

		// Name of the file we are parsing
		public string name;

		// Input stream to parse from.
		public System.IO.Stream input;

		public abstract int parse ();

		public virtual string[] extensions()
		{
			string [] list = { ".cs" };
			return list;
		}

		/// <summary>
		/// Emits error messages and increments a global count of them
		/// </summary>
		/// <param name="code"></param>
		/// <param name="desc"></param>
		public void error (int code, string desc)
		{
			Console.WriteLine ("Error "+code+": "+ desc);
			global_errors++;
		}

		// Emits error messages with location info.
		// FIXME : Ideally, all error reporting should happen
		// with Report.Error but how do you get at that non-static
		// method everywhere you need it ?
		public void error (int code, Mono.CSharp.Location l, string text)
		{
			Console.WriteLine (l.Name + "(" + l.Row + "," + 
					   "): Error CS" + code + ": " + text);
			global_errors++;
		}
		
		public GenericParser()
		{
			//
			// DO NOTHING: Derived classes should do their iniatilization here duties
			//
		}

		protected bool yacc_verbose_flag = false;

		public bool yacc_verbose
		{
			set
			{
				yacc_verbose_flag = value;
			}

			get
			{
				return yacc_verbose_flag;
			}
		}
	}
}



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Ivan Zderadièka

Czech Republic Czech Republic
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150427.4 | Last Updated 28 Jun 2002
Article Copyright 2002 by Ivan Zderadièka
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid