GithubHelp home page GithubHelp logo

value passthrough about packcc HOT 4 CLOSED

arithy avatar arithy commented on July 17, 2024
value passthrough

from packcc.

Comments (4)

arithy avatar arithy commented on July 17, 2024 1

Let me rewrite your expressions more precisely.
The rule definition way you want:
expression <- x:( rule_a / rule_b / rule_c / rule_d ) { $$ = x; }
The currently valid definition way:
expression <- a:rule_a { $$ = a; } / b:rule_b { $$ = b; } / c:rule_c { $$ = c; } / d:rule_d { $$ = d; }

If the syntax is limited to the manner below:
variable : ( rulename / rulename / ... )

  • only rule names exist in the parentheses,
  • rule names can be combined using only / operator, and
  • every rule name cannot have a respective prefixed variable,

it may be possible to realize this, but I cannot promise to do it soon.
I'll try to implement it whenever I have time.

from packcc.

0alfa avatar 0alfa commented on July 17, 2024

this macro works for now

#define PT                                                                     \
  pcc_value_refer_table_t _x = __pcc_in->data.leaf.values;                     \
  i(_x.len, I(_x.buf[i] && *_x.buf[i], NODE *n = ((NODE *)*_x.buf[i]);         \
              __ = *_x.buf[i]))

value <- (a:funclit / a:term) { PT; }

expands to

static void pcc_action_value_0(pcc_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in,
                               pcc_value_t *__pcc_out) {
  pcc_value_refer_table_t _x = __pcc_in->data.leaf.values;
  for (size_t i = 0; i < _x.len; i++) {
    if (_x.buf[i] && *_x.buf[i]) {
      NODE *n = ((NODE *)*_x.buf[i]);
      (*__pcc_out) = *_x.buf[i];
    };
  };
}

from packcc.

awrc avatar awrc commented on July 17, 2024

I've found that this works

expression <- (x:a / x:b / x:c / x:d) { $$ = x; }

from packcc.

arithy avatar arithy commented on July 17, 2024

@awrc , thank you for the helpful comment!
@0alfa , please use the syntax above. I'd like to close this issue as "not planned".

from packcc.

Related Issues (20)

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.