Skip to content

Commit

Permalink
Divide ctpg.d into modules
Browse files Browse the repository at this point in the history
  • Loading branch information
youxkei committed Apr 18, 2015
1 parent feadc4c commit b802cc5
Show file tree
Hide file tree
Showing 33 changed files with 6,779 additions and 7,649 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.dub/*
__test__library__
dub.selections.json
5 changes: 5 additions & 0 deletions Gemfile
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem 'guard'
gem 'guard-shell'
gem 'rb-readline'
53 changes: 53 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,53 @@
GEM
remote: https://rubygems.org/
specs:
celluloid (0.16.0)
timers (~> 4.0.0)
coderay (1.1.0)
ffi (1.9.8)
formatador (0.2.5)
guard (2.12.5)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-shell (0.7.1)
guard (>= 2.0.0)
guard-compat (~> 1.0)
hitimes (1.2.2)
listen (2.10.0)
celluloid (~> 0.16.0)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.9)
method_source (0.8.2)
nenv (0.2.0)
notiffany (0.0.6)
nenv (~> 0.1)
shellany (~> 0.0)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rb-readline (0.5.2)
shellany (0.0.1)
slop (3.6.0)
thor (0.19.1)
timers (4.0.1)
hitimes

PLATFORMS
ruby

DEPENDENCIES
guard
guard-shell
rb-readline
14 changes: 14 additions & 0 deletions Guardfile
@@ -0,0 +1,14 @@
# Add files and commands to this file, like the example:
# watch(%r{file/path}) { `command(s)` }
#

pre_mtime = nil

guard :shell do
watch %r{^(source|example)\/.*\.d$} do |files|
mtime = File.new(files[0]).mtime
msg = "\033[2J" + `dub test 2>&1` if pre_mtime != mtime
pre_mtime = mtime
msg
end
end
22 changes: 22 additions & 0 deletions dub.json
@@ -0,0 +1,22 @@
{
"name": "ctpg",
"description": "Compile Time Parser Generator",
"homepage": "https://github.com/youkei/ctpg",
"license": "CC0",
"dependencies": {
"compile-time-unittest": "~>0.0.1"
},

"targetType": "library",
"buildTypes": {
"unittest": {
"sourcePaths": ["source", "example"],
"buildOptions": ["unittests", "debugMode", "debugInfo"],
"dflags": [
"-unittest",
"-debug=ctpg",
"-debug=ctpgSuppressErrorMsg"
]
}
}
}
46 changes: 0 additions & 46 deletions example/calc_speed.d

This file was deleted.

36 changes: 18 additions & 18 deletions example/recursive_parsing.d
Expand Up @@ -4,29 +4,29 @@
* Example of recursive parsing.
*/

import ctpg;
import ctpg : parse;
import ctpg.none : None;
import ctpg.dsl.typed : CTPG_DSL_TYPED;

mixin (genParsers(
import compile_time_unittest : enableCompileTimeUnittest;
mixin enableCompileTimeUnittest;

mixin CTPG_DSL_TYPED!
q{
// root parser
None recursive = A $;

None A = !"a" !A !"a" / !"a";
}));
};

void main(){
static bool test(){
assert( parse!recursive("a").match);
assert( parse!recursive("aaa").match);
assert(!parse!recursive("aaaaa").match);
assert( parse!recursive("aaaaaaa").match);
assert(!parse!recursive("aaaaaaaaa").match);
assert(!parse!recursive("aaaaaaaaaaa").match);
assert(!parse!recursive("aaaaaaaaaaaaa").match);
assert( parse!recursive("aaaaaaaaaaaaaaa").match);
return true;
}
static assert(test());
test();
unittest
{
assert( parse!recursive("a").match);
assert( parse!recursive("aaa").match);
assert(!parse!recursive("aaaaa").match);
assert( parse!recursive("aaaaaaa").match);
assert(!parse!recursive("aaaaaaaaa").match);
assert(!parse!recursive("aaaaaaaaaaa").match);
assert(!parse!recursive("aaaaaaaaaaaaa").match);
assert( parse!recursive("aaaaaaaaaaaaaaa").match);
}

0 comments on commit b802cc5

Please sign in to comment.