Comments (4)
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.
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.
I've found that this works
expression <- (x:a / x:b / x:c / x:d) { $$ = x; }
from packcc.
@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)
- Peg only mode? HOT 9
- Parser very slow with repeated parse calls HOT 3
- Lexical state support HOT 5
- Import support HOT 10
- Questions not answered in the README HOT 12
- Passing auxil to PCC_DEBUG HOT 3
- AST Mode HOT 11
- Uninitialized variables HOT 8
- parser reads more data than necessary HOT 3
- Strange bad generated parser HOT 5
- Memory usage compared to gcc compiler HOT 13
- raising error from action? HOT 2
- %value and memory management HOT 2
- Consider add support for UCD(Unicode Character Database) rule pattern HOT 3
- Pre type checking possible? HOT 5
- Lookahead woes and more HOT 2
- Parsing a "switch { case n: m }"
- How to do good syntax error handling? HOT 2
- Null pointer error on broken grammar HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from packcc.