summaryrefslogtreecommitdiff
path: root/src/runtime/c/utils
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-10-04 12:04:39 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-10-04 12:04:39 +0000
commite8335806afc45e31157937b880ff39b75c14a2cd (patch)
tree5e3233cfdf934ff350f66d755bde759512ef5f20 /src/runtime/c/utils
parent27091048ce8276cc542e909588695d273e95b087 (diff)
GuString is now an ordinary C string - it makes live easier. In addition PgfSymbolKS, PgfExprFun and PgfLiteralStr now keep their strings as embedded flexible arrays. The latest change gives us the same compactness as the old representation but it is a lot easier to use.
Diffstat (limited to 'src/runtime/c/utils')
-rw-r--r--src/runtime/c/utils/pgf-parse.c8
-rw-r--r--src/runtime/c/utils/pgf-service.c10
-rw-r--r--src/runtime/c/utils/pgf-translate.c12
3 files changed, 15 insertions, 15 deletions
diff --git a/src/runtime/c/utils/pgf-parse.c b/src/runtime/c/utils/pgf-parse.c
index 692fec31e..2790e49de 100644
--- a/src/runtime/c/utils/pgf-parse.c
+++ b/src/runtime/c/utils/pgf-parse.c
@@ -28,8 +28,8 @@ int main(int argc, char* argv[]) {
goto fail;
}
char* filename = argv[1];
- GuString cat = gu_str_string(argv[2], pool);
- GuString lang = gu_str_string(argv[3], pool);
+ GuString cat = argv[2];
+ GuString lang = argv[3];
double heuristics = 0.95;
if (argc == 5) {
@@ -61,7 +61,7 @@ int main(int argc, char* argv[]) {
}
/* // Register a callback for the literal category Symbol */
- /* pgf_parser_add_literal(from_concr, gu_str_string("Symb", pool), */
+ /* pgf_parser_add_literal(from_concr, "Symb", */
/* &pgf_nerc_literal_callback); */
clock_t end = clock();
@@ -110,7 +110,7 @@ int main(int argc, char* argv[]) {
clock_t start = clock();
- GuIn *in = gu_string_in(gu_str_string(line, ppool), ppool);
+ GuIn *in = gu_string_in(line, ppool);
PgfLexer *lexer = pgf_new_simple_lexer(in, ppool);
GuEnum* result = pgf_parse_with_heuristics(concr, cat, lexer, heuristics, ppool, ppool);
diff --git a/src/runtime/c/utils/pgf-service.c b/src/runtime/c/utils/pgf-service.c
index 36b781a3f..f63b17f9f 100644
--- a/src/runtime/c/utils/pgf-service.c
+++ b/src/runtime/c/utils/pgf-service.c
@@ -200,8 +200,8 @@ int main ()
goto fail;
}
- GuString cat = gu_str_string("Phr", pool);
- GuString from_lang = gu_str_string("ParseEng", pool);
+ GuString cat = "Phr";
+ GuString from_lang = "ParseEng";
PgfConcr* from_concr =
pgf_get_language(pgf, from_lang);
if (!from_concr) {
@@ -210,7 +210,7 @@ int main ()
}
// Register a callback for the literal category Symbol
- pgf_parser_add_literal(from_concr, gu_str_string("Symb", pool),
+ pgf_parser_add_literal(from_concr, "Symb",
&pgf_nerc_literal_callback);
while (FCGI_Accept() >= 0) {
@@ -233,7 +233,7 @@ int main ()
PgfConcr* to_concr = NULL;
if (strlen(to_lang_buf) > 0) {
- GuString to_lang = gu_str_string(to_lang_buf, ppool);
+ GuString to_lang = to_lang_buf;
to_concr =
pgf_get_language(pgf, to_lang);
if (!to_concr) {
@@ -248,7 +248,7 @@ int main ()
sentence[len+1] = '\0';
GuReader *rdr =
- gu_string_reader(gu_str_string(sentence, ppool), ppool);
+ gu_string_reader(sentence, ppool);
PgfLexer *lexer =
pgf_new_simple_lexer(rdr, ppool);
diff --git a/src/runtime/c/utils/pgf-translate.c b/src/runtime/c/utils/pgf-translate.c
index cb3b1d6ec..aa98f1a7a 100644
--- a/src/runtime/c/utils/pgf-translate.c
+++ b/src/runtime/c/utils/pgf-translate.c
@@ -53,10 +53,10 @@ int main(int argc, char* argv[]) {
}
char* filename = argv[1];
- GuString cat = gu_str_string(argv[2], pool);
+ GuString cat = argv[2];
- GuString from_lang = gu_str_string(argv[3], pool);
- GuString to_lang = gu_str_string(argv[4], pool);
+ GuString from_lang = argv[3];
+ GuString to_lang = argv[4];
// Create an exception frame that catches all errors.
GuExn* err = gu_new_exn(NULL, gu_kind(type), pool);
@@ -91,7 +91,7 @@ int main(int argc, char* argv[]) {
}
// Register a callback for the literal category Symbol
- pgf_parser_add_literal(from_concr, gu_str_string("Symb", pool),
+ pgf_parser_add_literal(from_concr, "Symb",
&pgf_nerc_literal_callback);
// Create an output stream for stdout
@@ -154,7 +154,7 @@ int main(int argc, char* argv[]) {
ppool = gu_new_pool();
GuIn *in =
- gu_string_in(gu_str_string(line, ppool), ppool);
+ gu_string_in(line, ppool);
PgfLexer *lexer =
pgf_new_simple_lexer(in, ppool);
@@ -166,7 +166,7 @@ int main(int argc, char* argv[]) {
PgfToken tok =
pgf_lexer_current_token(lexer);
- if (gu_string_eq(tok, gu_empty_string))
+ if (*tok == 0)
gu_puts("Couldn't begin parsing", out, err);
else {
gu_puts("Unexpected token: \"", out, err);