$ template make_utils() $ $ output $basedir + '/Makefile.mono' # This file was generated by SableCC (http://www.sablecc.org/). # This is a simple UNIX makefile for C# generated parser # and the MONO project's tools all: parser.dll test_lexer.exe test_parser.exe FILES = nodes.cs tokens.cs prods.cs lexer.cs analysis.cs parser.cs parser.dll: $$(FILES) mcs -target:library -out:parser.dll $$(FILES) test_lexer.exe: test_lexer.cs parser.dll mcs -target:exe test_lexer.cs -r:parser.dll test_parser.exe: test_parser.cs parser.dll mcs -target:exe test_parser.cs -r:parser.dll docs: $$(FILES) doxygen clean: rm -f parser.dll test_lexer.exe test_parser.exe $ end output $ $ output $basedir + '/Makefile.dotgnu' # This file was generated by SableCC (http://www.sablecc.org/). # This is a simple UNIX makefile for C# generated parser # and the DOTGNU project's tools all: parser.dll test_lexer.exe test_parser.exe FILES = nodes.cs tokens.cs prods.cs lexer.cs analysis.cs parser.cs CSFLAGS = -g -O2 parser.dll: $$(FILES) cscc -o parser.dll $$(CSFLAGS) $$(FILES) test_lexer.exe: test_lexer.cs parser.dll cscc -o test_lexer.exe $$(CSFLAGS) test_lexer.cs -lparser.dll test_parser.exe: test_parser.cs parser.dll cscc -o test_parser.exe $$(CSFLAGS) test_parser.cs -lparser.dll docs: $$(FILES) doxygen clean: rm -f parser.dll test_lexer.exe test_parser.exe $ end output $ $ output $basedir + '/README.parser' This is a parser generated by SableCC (http://www.sablecc.org/). Please read on for instruction on how to use. The build system has been tuned towards UNIX make and either the Ximian MONO implementation of C# (http://www.go-mono.com/) or the DotGNU project (http://www.dotgnu.org/). It will most probably also compile on .NET and other C# implementations. This system generates a parser.dll assembly and couple of test applications. Just run: $$ make -f Makefile.mono or $$ make -f Makefile.dotgnu To run the test applications: $$ mono test_lexer.exe $$ mono test_parser.exe $$ mono test_parser.exe -ansi or for DotNET: $$ ilrun test_lexer.exe $$ ilrun test_parser.exe $$ ilrun test_parser.exe -ansi To use the generated parser just add parser.dll to your project's references. The C# parser follows very closely the model of the original SableCC's Java generated parser. I've also added files and options to generate Doxygen documentation. It will be created into docs/ directory when you run $$ make docs Doxygen's C# support is work in progress so I suggest you get the latest version (http://www.doxygen.org/). If you don't overwrite the make system (-b on sableccgen) you should be able to work in this directory adding new files and modifying Makefile-s. $ end output $ output $basedir + '/test_lexer.cs' /* This file was generated by SableCC (http://www.sablecc.org/). */ using System; using System.Collections; using System.Text; using System.IO; using @package.lexer; using @package.node; class TestLexer { public static void Main(String[] args) { Lexer l = new Lexer(Console.In); while (true) { Token token = l.Next(); Console.WriteLine ("Read token '" + token.GetType().Name + "', Text = [" + token.Text + "] at [" + token.Line + "," + token.Pos + "]"); if ( token is EOF ) break; } } } $ end output $ output $basedir + '/test_parser.cs' /* This file was generated by SableCC (http://www.sablecc.org/). */ using System; using System.Collections; using System.Text; using System.IO; using @package.parser; using @package.analysis; using @package.lexer; using @package.node; class TextPrinter : ReverseDepthFirstAdapter { enum codes { ESC = 27 }; enum style { NORMAL = 0, BOLD = 1, UNDERSCORE = 4, BLINK = 5, CONCEALED = 8 }; enum fg_color { FG_BLACK = 30, FG_RED = 31, FG_GREEN = 32, FG_YELLOW = 33, FG_BLUE = 34, FG_MAGENTA = 35, FG_CYAN = 36, FG_WHITE = 37 }; enum bg_color { BG_BLACK = 40, BG_RED = 41, BG_GREEN = 42, BG_YELLOW = 43, BG_BLUE = 44, BG_MAGENTA = 45, BG_CYAN = 46, BG_WHITE = 47 }; public TextPrinter () { } public override void OutStart (Start node) { Console.Write (TreeColor() + "\n" + output.Substring(3) + "\n" + ResetColor()); } public override void DefaultIn (Node node) { if ( last ) indentchar.Push('`'); else indentchar.Push('|'); indent = indent + " "; last = true; } public override void DefaultOut (Node node) { indent = indent.Substring(0, indent.Length - 3); indent = indent.Substring(0, indent.Length - 1) + indentchar.Peek(); indentchar.Pop(); output = indent + "- " + SetColor (style.NORMAL, fg_color.FG_GREEN, bg_color.BG_BLACK) + node.GetType().Name + TreeColor() + "\n" + output; indent = indent.Substring(0, indent.Length - 1) + "|"; } public override void DefaultCase (Node node) { if ( last ) indent = indent.Substring(0, indent.Length - 1) + "`"; output = indent + "- " + SetColor(style.NORMAL, fg_color.FG_RED, bg_color.BG_BLACK) + ((Token)node).Text + TreeColor() + "\n" + output; indent = indent.Substring(0, indent.Length - 1) + "|"; last = false; } string SetColor (style style, fg_color fgColor, bg_color bgColor) { if ( color ) return (char)codes.ESC + "[" + (int)style + ";" + (int)fgColor + "m"; return ""; } public override void CaseEOF (EOF node) { last = false; } string ResetColor () { if ( color ) return (char)codes.ESC + "[0m"; else return ""; } string TreeColor () { return SetColor (style.NORMAL, fg_color.FG_BLACK, bg_color.BG_BLACK); } public void SetColor (bool b) { color = b; } string indent, output; Stack indentchar = new Stack(); bool last = false; bool color = false; } class TestParser { public static void Main(String[] args) { Lexer l = new Lexer(Console.In); Parser p = new Parser (l); Start s = p.Parse (); TextPrinter printer = new TextPrinter (); if ( args.Length > 0 && args[0] == "-ansi" ) printer.SetColor(true); s.Apply(printer); } } $ end output $ output $basedir + '/Doxyfile' #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- PROJECT_NAME = @package #PROJECT_NUMBER = 0.1 OUTPUT_DIRECTORY = docs OUTPUT_LANGUAGE = English USE_WINDOWS_ENCODING = NO EXTRACT_ALL = YES EXTRACT_PRIVATE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = YES HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = YES HIDE_IN_BODY_DOCS = NO BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = YES FULL_PATH_NAMES = NO STRIP_FROM_PATH = INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES SHORT_NAMES = NO HIDE_SCOPE_NAMES = YES VERBATIM_HEADERS = YES SHOW_INCLUDE_FILES = YES JAVADOC_AUTOBRIEF = YES MULTILINE_CPP_IS_BRIEF = NO DETAILS_AT_TOP = NO INHERIT_DOCS = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES DISTRIBUTE_GROUP_DOC = NO TAB_SIZE = 8 GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ALIASES = ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_JAVA = NO SHOW_USED_FILES = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_FORMAT = "$$file:$$line: $$text" WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = nodes.cs tokens.cs prods.cs analysis.cs lexer.cs parser.cs FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.idl \ *.odl \ *.C \ *.H \ *.tlh \ *.diff \ *.patch \ *.moc \ *.xpm \ *.cs RECURSIVE = YES EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXAMPLE_PATH = EXAMPLE_PATTERNS = * EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = YES INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = NO REFERENCES_RELATION = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 3 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = htmlapi HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = doxygen.css HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = YES CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO BINARY_TOC = NO TOC_EXPAND = NO DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = YES PAPER_TYPE = a4 EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = YES USE_PDFLATEX = YES LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_SCHEMA = XML_DTD = #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::addtions related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = YES HIDE_UNDOC_RELATIONS = YES HAVE_DOT = YES CLASS_GRAPH = YES COLLABORATION_GRAPH = NO TEMPLATE_RELATIONS = YES INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES GRAPHICAL_HIERARCHY = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = MAX_DOT_GRAPH_WIDTH = 1024 MAX_DOT_GRAPH_HEIGHT = 1024 MAX_DOT_GRAPH_DEPTH = 1000 GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::addtions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = NO CGI_NAME = search.cgi CGI_URL = DOC_URL = DOC_ABSPATH = BIN_ABSPATH = /usr/local/bin/ EXT_DOC_PATHS = $ end output $ output $basedir + '/doxygen.css' body, table { font-family: Verdana, sans-serif; font-size: 10pt; } H1 { text-align: center; } CAPTION { font-weight: bold } a:link { color: #000080; } A.qindex {} A.qindexRef {} A.el { text-decoration: none; font-weight: bold; line-height:1.2em; } A.elRef { font-weight: bold } A.code { text-decoration: none; font-weight: normal; color: #4444ee } A.codeRef { font-weight: normal; color: #4444ee } A:hover { background-color: #f2f2ff } DL.el { margin-left: -1cm } DIV.fragment { width: 100%; border: none; background-color: #eeeeee } DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } TD.md { background-color: #f2f2ff; font-weight: bold; } TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; } TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; } DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold } DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller } BODY { background: white } TD.indexkey { background-color: #eeeeff; font-weight: bold; padding-right : 10px; padding-top : 2px; padding-left : 10px; padding-bottom : 2px; margin-left : 0px; margin-right : 0px; margin-top : 2px; margin-bottom : 2px } TD.indexvalue { background-color: #eeeeff; font-style: italic; padding-right : 10px; padding-top : 2px; padding-left : 10px; padding-bottom : 2px; margin-left : 0px; margin-right : 0px; margin-top : 2px; margin-bottom : 2px } .keyword { color: #008000 } .keywordtype { color: #604020 } .keywordflow { color: #e08000 } .comment { color: #800000 } .preprocessor { color: #806020 } .stringliteral { color: #002080 } .charliteral { color: #008080 } pre { font-family: Lucida Console, Courier New, monospace; font-size: 10pt; } p { line-height:1.2em; } td.head { color: white; background: #BFBED0 url("b2w.jpg") top repeat-x; padding-left:1.2cm; } @@media print { td.head { color: black; background: white; } body, table { font-family: Georgia, serif; } } $ end output $ end template