Comments (16)
No problem!
We're working through pull requests, thus you have to fork the repository first, then create your branch on your fork (git checkout -b branch_name
), which you have to clone on your PC.
Then, just make sure to make relevant commit message (eg, git add src/Compiler/MacroParser.cpp
, then git commit -m "adding first version of a macro parser"
), and when you are ready, git push -u origin branch_name
, and make a pull request on this repository, we'll review the code.
(I assumed you know a bit about git, if not, let me know and I can add more details)
The goal of having macros in the language would be (imo) to have a basic thing like C++ defines: #define thing(arg) std::cout << arg;
.
On the syntax side, I don't know yet if it could be directly in comments (if so we should avoid eliminating comments when lexing), like #(defmacro name arg1 arg2... body)
where (name arg1 arg2...)
would be replaced by body
; or if we should add keyword like macro
(working exactly like fun
): (let name (macro (arg1 arg2...) body))
.
As I am writing this, I think adding a keyword for this could be great.
On the "how should it work" side, macros could be evaluated by the compiler or not, then we just do some pattern matching and replace it accurately (I think it's a good solution since I'm planning to add a constant folding algorithm in the compiler). We can assume that a macro is correct (while forbidding nested macros like (let mac1 (macro (a) (macro (b) ...)))
) if the parser can parse it.
Thus macros would be eliminated after parsing, before compiling.
If you need more details, feel free to hit me up or join the discord
from ark.
Yes, I have basic knowledge of git, no issues with that. I understand how macros work. But haven't heard about nested macros. Will read it up and get back to you! Thanks a lot.
from ark.
About nested macros, that's because (iirc) in some lisp we can define a macro inside another, but here it's more basic, more like the C/C++ preprocessor
from ark.
No problem, I understand!
Good luck with your exams then :)
from ark.
Without any news, I'm taking the task
from ark.
Can I work on this?
from ark.
No problem, we'll just need to discuss what is needed before diving in!
from ark.
I am a beginner in Open source. I don't exactly know how to proceed but I am proficient with C++. Can you help me approach this?
from ark.
Hi there, just wanted to inform you that we're still discussing the syntax of macros, but it won't change how they work
from ark.
Yup, got that. Also, I wanted to ask how do I begin writing the code?
from ark.
You mean what to write and where or how to do it with git?
If it's with git, fork the repo and create a new branch (git checkout -b branch_name), and then as said before it's in the lexer/parser.
If that's about where and what, the best thing to start with will be to have a look at the lexer and the parser to understand how it works.
Then to add macros you would need to have a look at the parsing method of the parser (we established the syntax : !{name (args) body}
and !{name body}
), thus you would need to add a new kind of token in the lexer : !{
.
from ark.
Oh okay. I will do that. Thanks!
from ark.
Hi @sabiha22 !
Just wanted to check on you to know if you still want to work on this / already started to work on this!
from ark.
Hey! I do want to work on this but I have back to back exams so I am not able to take out much time for things other than academics. Really sorry :(
I will start working as soon as I am done with them.
from ark.
Hey! Really sorry for this, under a lot of pressure, won't be able to work on this. I apologize for the inconvenience.
from ark.
No problem, good luck with school!
from ark.
Related Issues (20)
- [Question] Evaluating code from a string HOT 1
- Macro processor segfaults when using undefined symbol HOT 1
- Null characters are crashing the VM
- Wrong number of arguments in a macro crashes the macro processor
- Write C++ the right way HOT 1
- Feature: add a code formatter to the CLI HOT 2
- CI: add a fuzzing step
- v4: integrate the new parser HOT 1
- VM shows invalid instruction on ARMv7 HOT 5
- Consider a smaller stack size
- Segmentation fault (core dumped) on import HOT 6
- Consider adding xmake support
- Rewrite the C++ tests to use a test framework
- Arkscript docker image has undefined symbols HOT 4
- Mention tool used for diagram in Code Structure section HOT 2
- Make the code formatter idempotent
- Enable `-Wall -Wextra -Wshadow -Wconversion -Wpedantic` HOT 2
- static analysis should run on each commit through precommit
- Create a fuzzing dictionary for arkscript
- [fuzzing] should we precompute a corpus?
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 ark.