Comments (4)
Might be good do note that when they are AST macros and you don't actually use a {{{body}}}
in there, then the following will NOT work:
macro for_stuff(n) { for (float i = 0; i < n; ++i) }
// used as
for_stuff(5) {
print("Foo\n");
}
because parsing the macro definition itself will give you a parse error about a missing body for the for
loop in it.
The nice part about ast macros is that a lot of checking (specifically syntax within the macro definition) will happen while parsing the macro definition, so if there's a syntax error it'll be shown in there. While with the preprocessor macros you'll end up getting an error at each use of the macro, and with huge macros it's hard to find the actual point of failure. Plus, there'll be syntax checking at the macro's use for the actual parameters directly.
It may be good to have the possibility to request a specific type in a macro parameter though. So that for instance the macro can create a counter variable accessible in the body by taking a variable-name as parameter. Note that in the above macro, the i
will not be accessible if we have hygienic macros!
from gmqcc.
Implementation wise we'd need to add copy-ctors to ast nodes. Which are also required for inlining.
So I'm referencing #35 here.
from gmqcc.
I would also like AST macros to return values (e.g. by also adding a syntax like gcc's ({ ... }) construct.
Furthermore, I would really also like a replacement for #ifdef
from gmqcc.
Will this work? If yes, why is x in the right scope? If no, why not?
macro do { {{{body}}} }
do { float x; }
do { float foo() { return x; } }
Or would it be better to have a second simple CPP mode that only supports argumentless #define/#undef and #ifdef/#else/#endif?
from gmqcc.
Related Issues (20)
- Binary download links are broken
- internal error when a qc function is called with an empty parameter HOT 2
- How should I compile this? HOT 1
- Segfault when variable and typedef share name
- Wrong column numbers
- Broken XOR assign HOT 1
- enum : flag uses incorrect incrementation with =
- frame macro syntax broken with C-style functions HOT 1
- operator != and == does not work with comparisons against nil HOT 1
- invalid types for variable argument function assignment
- Broken char literals get accepted
- Inconsistent math with multiple assignments to the same variable HOT 2
- for loop bug HOT 7
- if(cond) + break; issue with -O3 HOT 1
- if bug HOT 1
- multiple constants with same value HOT 1
- A way to run GMQCC as a linter HOT 5
- Repository and fork
- failed to open `progs.src` for reading when in subdirectory
- Deduplicate emitted opcodes variants
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 gmqcc.