Skip to content

Commit

Permalink
codec: printl for prz
Browse files Browse the repository at this point in the history
  • Loading branch information
benl23x5 committed Mar 14, 2020
1 parent eef31aa commit 34add0c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
36 changes: 19 additions & 17 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,40 @@

The Reflective Lambda Machine with Cold Storage

This project is just getting started, so not much works yet.

Shivver is a minimal Scheme-like language intended as an intermediate language for
the reflective bootstrapping of higher level languages.
Shivver is a minimal Scheme-like language intended for the as an intermediate language for
reflective bootstrapping of higher level languages.

Shivver is an evolution of the older [Shimmer](https://github.com/discus-lang/shimmer) language,

The implementation is plain, portable C99 code.

This project is just getting started, so not much works yet.


## Grammar

```
Decl ::= '@' Name '=' Term ';'
Module ::= module Name Decl* '!shivver' Name Decl*
Decl ::= decl Name Term '@' Name '=' Term ';'
Term ::= mvar Name Nat (like 'name^5')
| msym Name (like '%name)
| mprm Name (like '#name)
| mmac Name (like '@mac)
Term ::= mvar Name Nat (like 'name^5')
| msym Name (like '%name')
| mprm Name (like '#name')
| mmac Name (like '@mac')
| mmmm n Term^n '[' Term,* ']'
| mmmm n Term^n '[' Term,* ']'
| mabs n Name^n Term '{' Name* '}' Term
| mapp Term Term Term Term
| mabs n Name^n Term '{' Name* '}' Term
| mapp Term Term Term Term
| mlet Name Term Term '!let' Name '=' Term '!in' Term
| mrec Binds Term '!rec' Binds '!in' Term
| mlet Name Term Term '!let' Name '=' Term '!in' Term
| mrec Binds Term '!rec' Binds '!in' Term
Binds ::= bind1 bind Bind
| binds Binds Bind '!and' Binds
Binds ::= bind1 bind Bind
| binds Binds Bind '!and' Binds
Bind ::= bind Name '=' Term Name '=' Term
Bind ::= bind Name '=' Term Name '=' Term
```


Expand Down
3 changes: 2 additions & 1 deletion src/shivver/codec/ascii.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#define TOKEN_SKET 15

#define TOKEN_COMMA 20
#define TOKEN_EQ 21
#define TOKEN_SEMI 21
#define TOKEN_EQ 22

#define TOKEN_VAR 30
#define TOKEN_SYM 31
Expand Down
1 change: 1 addition & 0 deletions src/shivver/codec/ascii/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ bool shivver_lexer_scan
case '[': *outTag = TOKEN_SBRA; goto single;
case ']': *outTag = TOKEN_SKET; goto single;
case ',': *outTag = TOKEN_COMMA; goto single;
case ';': *outTag = TOKEN_SEMI; goto single;
case '=': *outTag = TOKEN_EQ; goto single;

// symbol name
Expand Down
6 changes: 3 additions & 3 deletions src/shivver/codec/ascii/parse/decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ shivver_parse_decl
shivver_parse_peek(state);

switch (state->peek_tok)
{ // Term ::= !term Mac '=' Term
case TOKEN_KEY_TERM:
{ // Term ::= Mac '=' Term
case TOKEN_MAC:
{ shivver_parse_shift(state);
obj_t* oMac = shivver_parse_mac(state);
obj_t* oMac = aMacA(state->curr_len - 1, state->curr_str + 1);
shivver_parse_tok(state, TOKEN_EQ);
obj_t* oBody = shivver_parse_term1(state);
return aApsH (2, aSymT("decl"), (obj_t*[]){oMac, oBody});
Expand Down
10 changes: 10 additions & 0 deletions src/shivver/prim/console/printl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ shivver_prim_console_printl
return;
}

case TAG_MACA:
{ printf("@%s", xMacA_name(obj));
return;
}

case TAG_SYMA:
{ printf("%%%s", xSymA_name(obj));
return;
Expand All @@ -24,6 +29,11 @@ shivver_prim_console_printl
return;
}

case TAG_PRZA:
{ printf("#%s", shivver_prim_tag_name(xPrzA_tag(obj)));
return;
}

case TAG_NATA:
{ printf("#nat'%llu", xNatA(obj));
return;
Expand Down

0 comments on commit 34add0c

Please sign in to comment.