Comments (5)
The masking system is a little complicated. I can think of 2 possible reasons for this problem:
- ARR ID is colliding with some existing type making the operation be processed by some built-in one instead of the one you were expecting.
- You have defined a more specific operation for this same types, e.g.
opMap.add({ANY_TYPE, "=%", ANY_TYPE})
@astlin can you provide the code you use to declare all your operations as well as the hex numeral of ARR
? Then I should be able to diagnose what is happening.
from cparse.
Well, actually there is a declaration of '=%' for ANY_TYPE on ANY_TYPE right before the last one 'ANY ANY ANY'.
opMap.add({ARR, ANY_OP, ANY_TYPE}, &ArrayOnAnyOperation);
opMap.add({ARR, "=%", ANY_TYPE}, &ArrayOnAnyOperation);
....
opMap.add({ANY_TYPE, "=%", ANY_TYPE}, &AnyLike);
opMap.add({ANY_TYPE, ANY_OP, ANY_TYPE}, &AnyOnAny);
from cparse.
This {ANY, =%, ANY}
operation is most likely taking precedence.
The ANY_OP
operations are only evaluated if there is no match with a specific operation, quoting the code:
// Resolve the operation:
result = exec_operation(p_left, p_right, &data, data.op);
if (!result) {
// ANY_OP will only run if no other match is found:
result = exec_operation(p_left, p_right, &data, ANY_OP);
}
This could probably be better explained in the docs. In any case I suggest you group your ANY_OP
operation declarations and set put them after the rest, so it will be more clear the actual precedence order:
// The order is important between 2 operations with the same operator
// So ARR "=%" ANY will have precedence over ANY "=%" ANY
opMap.add({ARR, "=%", ANY_TYPE}, &ArrayOnAnyOperation);
opMap.add({ANY_TYPE, "=%", ANY_TYPE}, &AnyLike);
// Likewise {ARR ANY_OP ANY} will have precedence over {ANY ANY_OP ANY}
// But ANY_OP will always have less precedence than specific operations so they should
// be put in last to make it clear.
opMap.add({ARR, ANY_OP, ANY_TYPE}, &ArrayOnAnyOperation);
opMap.add({ANY_TYPE, ANY_OP, ANY_TYPE}, &AnyOnAny);
I will add this example to the docs and then, if it works for you, close this issue.
from cparse.
I have updated the doc section on this, and it should be clearer now.
Let me know if this helps.
from cparse.
Ok. Thanx for explanation.
from cparse.
Related Issues (20)
- exception on simple calculatorexample
- Segmentation fault on bad inputs
- group/vector operation possible? Naive iteration can be expensive when number of elements is huge HOT 5
- terminating with uncaught exception of type syntax_error: Invalid operator: - HOT 4
- Token names cannot have UTF8 characters HOT 4
- Project doesn't install anything HOT 10
- Syntax errors cause crashes HOT 21
- Hexadecimal number computation HOT 4
- calculator ignores variable HOT 3
- Consider adding a namespace to cparse code HOT 6
- Program treats "." in numeric "0.x" as an operator and throw an exception! HOT 5
- Thread Safety HOT 4
- Is not operator supported? HOT 1
- Warning c4099 is everywhere. HOT 3
- Invalid operators, but with ALL operators HOT 1
- It doesn't compile in Windows and Linux, am I doing something wrong? HOT 3
- Buffer-overflow (out-of-bounds read) occured in two positions HOT 1
- cparse/builtin-features/operators.inc HOT 9
- Solved. Errors with Linux emulator using GCC. HOT 22
- TokenMap value change to None,when using getChild() HOT 6
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 cparse.