aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-07-30 03:28:46 +0000
committerMike Buland <eichlan@xagasoft.com>2006-07-30 03:28:46 +0000
commit28e92029752693ffe33de12c10de3e7bd39a3c94 (patch)
tree932b447a558a3278311e55b495070f2683c3acec
parent3d8c367fb6160486b63b19b5d156adfeac621b34 (diff)
downloadbuild-28e92029752693ffe33de12c10de3e7bd39a3c94.tar.gz
build-28e92029752693ffe33de12c10de3e7bd39a3c94.tar.bz2
build-28e92029752693ffe33de12c10de3e7bd39a3c94.tar.xz
build-28e92029752693ffe33de12c10de3e7bd39a3c94.zip
Figured out a format I like, we'll see what happens.
-rw-r--r--congo26
-rw-r--r--regexptest.cpp47
-rw-r--r--src/build.l31
-rw-r--r--src/build.y0
-rw-r--r--src/lexer.flex13
5 files changed, 91 insertions, 26 deletions
diff --git a/congo b/congo
index 336a196..ddf7e7b 100644
--- a/congo
+++ b/congo
@@ -1,16 +1,16 @@
1 1
2target( all ) 2default action: create congo, congod
3{
4 build( congo );
5 build( congod );
6}
7 3
8target( congo ) 4create file congod from files in src/congod using rule exe
9{ 5create file congo from files in src/congo using rule exe
10 type = executable;
11 linker = c++;
12
13 uses( src/congo );
14 uses( src/congod );
15}
16 6
7congod requires libcongo.a
8congo requires libcongo.a
9
10set CXXFLAGS += "-Ilibbu++/src"
11set LDFLAGS += "-Llibbu++ -lbu++"
12
13for congo set LDFLAGS += "-lreadline"
14
15rule exe matches all /(.*)\.o/ perform command "g++ {matches} {LDFLAGS} -o {target}"
16rule cpp matches one /(.*)\.cpp/ produces {1}.o perform command "g++ {CXXFLAGS} -o {target} {match}"
diff --git a/regexptest.cpp b/regexptest.cpp
new file mode 100644
index 0000000..01597be
--- /dev/null
+++ b/regexptest.cpp
@@ -0,0 +1,47 @@
1#include <stdio.h>
2#include <regex.h>
3#include <string>
4
5int test( const char *str, const char *sRegExp )
6{
7 printf("Compiling: %s\n", sRegExp );
8 regex_t r;
9 if( regcomp( &r, sRegExp, REG_EXTENDED|REG_NEWLINE ) )
10 {
11 printf("Error compiling regular expression.\n");
12 return 0;
13 }
14
15 printf("Compiled, %d sub expressions.\n", r.re_nsub );
16
17 int nMatch = r.re_nsub+1;
18 regmatch_t *match = new regmatch_t[nMatch];
19 if( regexec( &r, str, nMatch, match, 0 ) )
20 {
21 printf("Regular expression did not match.\n");
22 return 0;
23 }
24
25 printf("Match!\nSubstrings:\n");
26 for( int j = 0; j < nMatch; j++ )
27 {
28 printf(" %d: (%d-%d) %s\n",
29 j,
30 match[j].rm_so, match[j].rm_eo,
31 std::string(str+match[j].rm_so, match[j].rm_eo-match[j].rm_so ).c_str()
32 );
33 }
34
35 delete[] match;
36 regfree( &r );
37}
38
39int main( int argc, char *argv[] )
40{
41 printf("Regular expression test:\n\n");
42
43 test( argv[1], argv[2] );
44
45 return 0;
46}
47
diff --git a/src/build.l b/src/build.l
new file mode 100644
index 0000000..6daaa94
--- /dev/null
+++ b/src/build.l
@@ -0,0 +1,31 @@
1 int lineNum = 1;
2%%
3
4[,:=] return yytext[0];
5"+=" return TOK_ADDSET;
6
7"default" return TOK_DEFAULT;
8"action" return TOK_ACTION;
9"create" return TOK_CREATE;
10"file" return TOK_FILE;
11"from" return TOK_FROM;
12"files" return TOK_FILES;
13"in" return TOK_IN;
14"using" return TOK_USING;
15"rule" return TOK_RULE;
16"requires" return TOK_REQUIRES;
17"for" return TOK_FOR;
18"set" return TOK_SET;
19"matches" return TOK_MATCHES;
20"all" return TOK_ALL;
21"one" return TOK_ONE;
22"perform" return TOK_PERFORM;
23"produces" return TOK_PRODUCES;
24"command" return TOK_COMMAND;
25
26\n+ return TOX_EOL;
27[ \t\r]*
28
29\/\/.*
30"#".*
31
diff --git a/src/build.y b/src/build.y
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/build.y
diff --git a/src/lexer.flex b/src/lexer.flex
deleted file mode 100644
index 508a50c..0000000
--- a/src/lexer.flex
+++ /dev/null
@@ -1,13 +0,0 @@
1 int lineNum = 1;
2%%
3
4"="|"("|")"|"{"|"}"|";"|"," return yytext[0];
5"==" return TOK_COMPARE;
6"target" return TOK_TARGET;
7
8\n ++lineNum;
9[ \t\r]*
10
11\/\/.*
12"#".*
13