Giter Club home page Giter Club logo

packcc's People

Contributors

leandros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

packcc's Issues

C++ compatibility (one-line fix)

The generated parsers don't compile as C++, because of one call that implicitly casts from void* to a concrete pointer. It's easy to fix by changing the type-cast from (void *) to pcc_action_t):

diff --git a/src/packcc.c b/src/packcc.c
index dc6b8ed..a514fea 100644
--- a/src/packcc.c
+++ b/src/packcc.c
@@ -2561,7 +2561,7 @@ code_reach_t generate_thunking_action_code(
         fputs("pcc_value_t null;\n", gen->stream);
     }
     write_characters(gen->stream, ' ', indent);
-    fprintf(gen->stream, "pcc_thunk_t *thunk = pcc_thunk__create_leaf(ctx->auxil, (void *)pcc_action_%s_%d, %d, %d);\n",
+    fprintf(gen->stream, "pcc_thunk_t *thunk = pcc_thunk__create_leaf(ctx->auxil, (pcc_action_t)pcc_action_%s_%d, %d, %d);\n",
         gen->rule->data.rule.name, index, gen->rule->data.rule.vars.len, gen->rule->data.rule.capts.len);
     {
         int i;

Failure to backtrack; trivial `?` expression fails

I've written a grammar but it's failing even on trivial inputs. I've boiled the grammar down to the following simple test case:

%prefix "test"

property <-
    ( IDENTIFIER '.' )? IDENTIFIER    { printf("PROPERTY: %s\n", $0);}
IDENTIFIER <-
    [a-zA-Z_] [a-zA-Z_0-9]*

%%
int main() {
    test_context_t *ctx = test_create(NULL);
    return test_parse(ctx, NULL);
}

This is able to parse input foo.bar but fails on foo:

$ packcc test.packcc && cc test.c -o test && echo "foo.bar" | ./test
PROPERTY: foo.bar
$ packcc test.packcc && cc test.c -o test && echo "foo" | ./test
Syntax error

It looks as though the parser is unable to recover from the failure to match the ( IDENTIFIER '.' ) rule. I suspect it isn't backtracking in the input, so when it hits the second IDENTIFIER there's nothing left to parse.

Here's evidence in favor of that. If I change the property rule to this:

property <-
    ( IDENTIFIER '.' )? ' ' IDENTIFIER

the parser will successfully parse the input foo bar, which is incorrect. So it appears that it consumed the foo, failed to match a ., then went on without backtracking and matched the space and bar.

This seems like a really elementary failure. Is this software considered stable or is it just an experiment? (I'm not trying to be sarcastic. I've put experimental stuff up on Github, there's nothing wrong with that. I just try to label it as such. I'm trying to use PackCC for a work project and don't want to waste more time trying to debug it if it's not ready...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.