Skip to content

Commit

Permalink
Merge pull request #49 from nickel-lang/feat/namespaced-primops
Browse files Browse the repository at this point in the history
Add support for extend primop II
  • Loading branch information
yannham authored Jun 4, 2024
2 parents 9b15abb + 71e702b commit 43433d8
Show file tree
Hide file tree
Showing 6 changed files with 1,702 additions and 1,621 deletions.
10 changes: 8 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,15 @@ module.exports = grammar({
//grammar.lalrpop: 509
// Different from lalrpop grammar, we parse all possible builtins, not just
// the defined ones.
builtin: $ => seq(
builtin: _ => seq(
"%",
$.ident,
// We are a bit more liberal with what can go in a builtin function than
// for identifiers, because builtins are properly delimited by `%`.
// Upstream Nickel added `/` as a valid character already, so there's a
// precendent for extensions (although it's not very likely), so we try to
// be a bit future-proof. We just make sure the builtin starts with either
// a letter or an undescore, to ensure reasonable names.
/_*[a-zA-Z][a-zA-Z0-9./_'-]*/,
"%",
),

Expand Down
4 changes: 2 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1909,8 +1909,8 @@
"value": "%"
},
{
"type": "SYMBOL",
"name": "ident"
"type": "PATTERN",
"value": "_*[a-zA-Z][a-zA-Z0-9./_'-]*"
},
{
"type": "STRING",
Expand Down
12 changes: 1 addition & 11 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,7 @@
{
"type": "builtin",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "ident",
"named": true
}
]
}
"fields": {}
},
{
"type": "chunk_expr",
Expand Down
Loading

0 comments on commit 43433d8

Please sign in to comment.