-
Install the dependencies (Git, CMake, Doxygen, GLib, GObject, C compiler) for your platform.
-
git clone https://github.com/YourNameGoesHereButDontTypeThisInLiterally/CompilerKit.git cd CompilerKit git submodule init # This project has submodules in it, so do this first (one time). git submodule update # This project has submodules in it, so do this first (one time).
-
Add me as upstream, and add in your collaborators, too.
git remote add upstream https://github.com/lawrancej/CompilerKit.git ./collaborators.sh setup
-
./generate.sh build # Builds tests only ./generate.sh build -DBUILD_EXAMPLES=ON # Builds all examples ./generate.sh build -DBUILD_SCANNER_DEMO=ON # Builds the scanner demo only
-
./generate.sh docs
-
git pull upstream master # Get the latest and greatest. git checkout -b issueXYZ # Work on an issue in a new topic branch, based off of the upstream master branch. ... Hack away ... # Your new code compiles and the tests pass, right? git commit -a -m "Fixed issueXYZ" # Great! Commit your changes. git push origin issueXYZ # Push your changes to your repo. Send in a pull request. git checkout master # Switch back to master. Rinse and repeat.
You will need to download and install everything manually. Therefore, verify everything is working first before building CompilerKit.
- Visual Studio 2010 or MinGW
- Git (version control).
- CMake.
- Doxygen.
- GLib and GObject. Extract to
C:\glib
. AddC:\glib\bin
to the system PATH. - GrahpViz.
- StarUML to examine UML diagrams. We should switch to cross-platform Dia, since StarUML only works on Windows.
Open Git Bash to the CompilerKit
folder. Type in the first line. Did you see the rest? You should.
pkg-config --list-all
gio-2.0 GIO - glib I/O library
gmodule-2.0 GModule - Dynamic module loader for GLib
glib-2.0 GLib - C Utility Library
gmodule-no-export-2.0 GModule - Dynamic module loader for GLib
gthread-2.0 GThread - Thread support for GLib
gobject-2.0 GObject - GLib Type, Object, Parameter and Signal Library
Did you see command not found
after typing these into Git Bash? You should not.
doxygen
cmake
-
Open
regedit
-
Navigate to the following location and select
Windows Error Reporting
:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting
-
Select
Edit -> New -> DWORD (32-bit value)
-
Replace
New Value #1
withDontShowUI
-
Double click
DontShowUI
. Enter1
for value data. Click OK. -
Exit
regedit
If you installed MSYS, do the following to build all the examples:
./generate.sh build -G '"MSYS Makefiles"' -DBUILD_EXAMPLES=ON
In the terminal, paste this in for your distribution:
sudo yum install git cmake doxygen glib-devel pkgconfig 'graphviz*'
sudo apt-get install git cmake doxygen libglib2.0-dev pkg-config graphviz
If you do not already have it, install:
In the terminal, paste this in:
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.githubusercontent.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
Once installed, paste this into the Terminal:
brew install git cmake doxygen glib pkg-config
If you see the following error when using CMake on the Mac:
build User$ cmake ..
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:/Users/User/CompilerKit/build/CMakeFiles/CMakeCCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Follow these steps to fix the error:
- Open XCode
- Go to Preferences
- Download tab
- Install Command line
Easy! Type this in:
./generate.sh build
If you get build errors that you know shouldn't be there, try rebuild:
./generate.sh rebuild
To run the test suite, type:
./generate.sh test
To get a coverage report, type this (if on MSYS, do this first):
./generate.sh coverage
CompilerKit uses Doxygen to generate documentation. Do this to generate and view documentation:
./generate.sh docs
Also, read up on GLib and GObject.
Doxygen generates documentation in HTML, LaTeX, RTF (MS-Word) using specially-formatted comments. It can also extract the code structure from undocumented source files for many programming languages (C/C++, Java, Python, etc).
Example comment:
/**
* compilerkit_visitor_register:
* @fn compilerkit_visitor_register
* @memberof CompilerKitVisitor
* Associate the GType of a class with a visitor function.
* @pre CompilerKitVisitor* is not NULL.
* @param CompilerKitVisitor* The visitor instance.
* @param GType The type of the class to visit.
* @param CompilerKitVisitorFunc A pointer to a visitor function for the specified type.
* @return void
*/
The folder structure of CompilerKit is as follows:
.boilerplate Contains boilerplate classes for writing new GObject classes.
AUTHORS A list of people who contribute to the project.
CMakeLists.txt CMake configuration file for generating Makefiles.
CONVENTIONS.md How to write code without looking stupid.
COPYING The license (LGPL 2.1+)
Doxyfile Doxygen configuration.
HACKING.md This file.
README.md The readme.
TODO.md A list of TODO items.
build/ Where the build goes (git ignores this)
collaborators.sh Configure git to add all AUTHORS into your git remotes for you
dependencies/ A folder containing project dependencies. Currently, just the latest from lcov CVS.
docs/ All generated documentation goes there. Read it!
examples/ Source code demonstrations for how to use each class. Shows up in the documentation.
generate.sh The Swiss-Army knife: it does everything.
images/ Miscellaneous images in project documentation
include/ The include files for the CompilerKit library.
src/ The CompilerKit library source code.
tests/ The test suite to exercise the CompilerKit library.
The regex classes are: CompilerKitSymbol
, CompilerKitEmptySet
, CompiletKitEmptystring
, CompilerKitConcatenation
, CompilerKitAlternation
, CompilerKitKleeneStar
, CompilerKitComplement
.
The cfg classes are: CompilerKitGrammar
, CompilerKitTerminal
, CompilerKitNonterminal
, CompilerKitProduction
.
We use github's issue tracker to manage our participation:
- Work on open issues in github's issue tracker (comment on issues to get dibs).
- Pro tip: pair up and split the work on an issue with someone else. E.g., you test and document, they implement.
- Open new issues.
- Write test cases for inadequately covered code (see existing test cases for ideas).
- Improve the documentation (see existing documentation for ideas).
Review code, tests, and documentation for quality issues (comment on pull requests).
- Does the code compile and make sense?
- Did it handle all cases? Check the coverage report.
Topic branches isolate chunks of work so that it's easier to merge in changes. Here's how it works:
git pull upstream master
git checkout -b issueXYZ # Create a new local branch issueXYZ
... Hack away ...
git commit -a -m "Work in progress on issueXYZ"
git push origin issueXYZ # Push local branch to remote repo
git checkout master
I will not merge code into my master branch until:
- The project builds successfully.
- It has a demo (see
examples/
). - Test cases pass in the test suite (see
tests/test.c
andtests/test.h
) - The documentation looks as expected.
Look for the demo and test suite executables in these folders:
build/Debug
(Windows)build
(Mac, Linux)
Switch to your branch in github, and send in a pull request that describes what you did. Do so when you think your changes are ready to be merged in. But do not hesitate to push works in progress.
GLib is a C utility library similar to the Standard Template Library in C++. It provides data structures as well as GObject.
To use it, read these first:
Let's compare with some examples.
GObject Java/C#
(prefix everything with COMPILERKIT) package CompilerKit;
COMPILERKIT_IS_ALTERNATION(obj) (obj instanceof Alternation)
COMPILERKIT_ALTERNATION (obj) (Alternation) obj
COMPILERKIT_TYPE_ALTERNATION Alternation.class
G_OBJECT_TYPE (obj) obj.getClass()
compilerkit_alternation_get_left(alt) alt.getLeft()
GObject may seem intimidating. Learn how it works, and realize that OOP languages provide a lot of shortcuts that C exposes to the programmer.
To use GObject, read these first:
Run ./generate.sh
, and follow the instructions.