Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add macros #9

Merged
merged 17 commits into from
Sep 24, 2024
Merged

Feat/add macros #9

merged 17 commits into from
Sep 24, 2024

Conversation

grantwforsythe
Copy link
Owner

@grantwforsythe grantwforsythe commented Sep 19, 2024

Overview

Add (very buggy) macro system which utilizes three new key words:

  1. quote - stops the evaluation of a node and returns a quote object
  2. unquote - evaluate a node
  3. macro - define a new macro which returns a quote object by definition

Example

>> let unless = macro(condition, consequence, alternative) {
  quote(
    if (!(unquote(condition))) {
      unquote(consequence); 
    } else { 
      unquote(alternative); 
    }
  );
}
>> unless(10 > 5, puts("10 is greater than 5"), puts("10 is not greater than 5")
"10 is greater than 5" -- notice that null is not outputted and the other puts statement is not evaluated

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 58.85417% with 79 lines in your changes missing coverage. Please review.

Project coverage is 70.29%. Comparing base (11b0f13) to head (91a84de).
Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
pkg/object/object.go 0.00% 31 Missing ⚠️
pkg/ast/ast.go 0.00% 13 Missing ⚠️
pkg/evaluator/macro_expansion.go 86.20% 5 Missing and 3 partials ⚠️
pkg/ast/modify.go 86.95% 5 Missing and 1 partial ⚠️
pkg/object/environment.go 0.00% 5 Missing ⚠️
pkg/evaluator/builtins.go 0.00% 4 Missing ⚠️
pkg/evaluator/quote_unqote.go 78.94% 2 Missing and 2 partials ⚠️
pkg/parser/parser.go 60.00% 2 Missing and 2 partials ⚠️
pkg/repl/repl.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #9      +/-   ##
==========================================
- Coverage   72.00%   70.29%   -1.71%     
==========================================
  Files          11       14       +3     
  Lines         925     1111     +186     
==========================================
+ Hits          666      781     +115     
- Misses        225      288      +63     
- Partials       34       42       +8     
Files with missing lines Coverage Δ
pkg/evaluator/evaluator.go 84.95% <100.00%> (+0.94%) ⬆️
pkg/lexer/lexer.go 95.09% <ø> (ø)
pkg/strings/strings.go 100.00% <ø> (ø)
pkg/token/token.go 100.00% <ø> (ø)
pkg/evaluator/builtins.go 87.83% <0.00%> (-5.02%) ⬇️
pkg/evaluator/quote_unqote.go 78.94% <78.94%> (ø)
pkg/parser/parser.go 79.13% <60.00%> (-0.79%) ⬇️
pkg/repl/repl.go 0.00% <0.00%> (ø)
pkg/object/environment.go 0.00% <0.00%> (ø)
pkg/ast/modify.go 86.95% <86.95%> (ø)
... and 3 more

@grantwforsythe grantwforsythe added the enhancement New feature or request label Sep 22, 2024
@grantwforsythe grantwforsythe marked this pull request as ready for review September 24, 2024 02:49
@grantwforsythe grantwforsythe merged commit 570e324 into main Sep 24, 2024
4 of 5 checks passed
@grantwforsythe grantwforsythe deleted the feat/add-macros branch September 24, 2024 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant