Giter Club home page Giter Club logo

Comments (16)

SuperFola avatar SuperFola commented on August 15, 2024 1

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.

sabiha22 avatar sabiha22 commented on August 15, 2024 1

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.

SuperFola avatar SuperFola commented on August 15, 2024 1

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.

SuperFola avatar SuperFola commented on August 15, 2024 1

No problem, I understand!

Good luck with your exams then :)

from ark.

SuperFola avatar SuperFola commented on August 15, 2024 1

Without any news, I'm taking the task

from ark.

sabiha22 avatar sabiha22 commented on August 15, 2024

Can I work on this?

from ark.

SuperFola avatar SuperFola commented on August 15, 2024

No problem, we'll just need to discuss what is needed before diving in!

from ark.

sabiha22 avatar sabiha22 commented on August 15, 2024

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.

SuperFola avatar SuperFola commented on August 15, 2024

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.

sabiha22 avatar sabiha22 commented on August 15, 2024

Yup, got that. Also, I wanted to ask how do I begin writing the code?

from ark.

SuperFola avatar SuperFola commented on August 15, 2024

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.

sabiha22 avatar sabiha22 commented on August 15, 2024

Oh okay. I will do that. Thanks!

from ark.

SuperFola avatar SuperFola commented on August 15, 2024

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.

sabiha22 avatar sabiha22 commented on August 15, 2024

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.

sabiha22 avatar sabiha22 commented on August 15, 2024

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.

SuperFola avatar SuperFola commented on August 15, 2024

No problem, good luck with school!

from ark.

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.