skw->silent; kw->keyword

This commit is contained in:
Scott Richmond 2023-11-27 01:18:30 -05:00
parent 41fcdaa2e5
commit 62b1484829

View File

@ -6,12 +6,12 @@ line { (expression | toplevel) terminator+ }
toplevel { Import | Use | Ns } toplevel { Import | Use | Ns }
Import { skw<"import"> String skw<"as"> Word } Import { silent<"import"> String silent<"as"> Word }
Use { skw<"use"> Word } Use { silent<"use"> Word }
Ns { Ns {
skw<"ns"> Word "{" silent<"ns"> Word "{"
separator* separator*
assoc_term (separator+ assoc_term)* assoc_term (separator+ assoc_term)*
separator* separator*
@ -22,7 +22,7 @@ expression { non_binding | binding }
binding { Let | Ref | Fn_Named | Fn_Compound } binding { Let | Ref | Fn_Named | Fn_Compound }
Ref { skw<"ref"> Word "=" expression } Ref { silent<"ref"> Word "=" expression }
non_binding { simple | complex } non_binding { simple | complex }
@ -56,13 +56,13 @@ complex {
| Each | Each
} }
Repeat { skw<"repeat"> (Word | Number) Block } Repeat { silent<"repeat"> (Word | Number) Block }
Each { skw<"each"> simple "do" (Fn_Clause | Fn_Clauses) } Each { silent<"each"> simple "do" (Fn_Clause | Fn_Clauses) }
Recur { skw<"recur"> Args } Recur { silent<"recur"> Args }
Loop { skw<"loop"> simple "with" (Fn_Clause | Fn_Clauses) } Loop { silent<"loop"> simple "with" (Fn_Clause | Fn_Clauses) }
simple { atom | collection | Synthetic | Fn_Lambda | Recur } simple { atom | collection | Synthetic | Fn_Lambda | Recur }
@ -76,21 +76,21 @@ Fn_Clauses {
"}" "}"
} }
Fn_Compound { skw<"fn"> Word Fn_Clauses } Fn_Compound { silent<"fn"> Word Fn_Clauses }
Fn_Named { skw<"fn"> Word Fn_Clause } Fn_Named { silent<"fn"> Word Fn_Clause }
Fn_Lambda { skw<"fn"> Fn_Clause } Fn_Lambda { silent<"fn"> Fn_Clause }
// TODO: figure out precedence with do/bind exprs // TODO: figure out precedence with do/bind exprs
// do_expr { Fn_Lambda | Synthetic | Word | Keyword } // do_expr { Fn_Lambda | Synthetic | Word | Keyword }
// Do { // Do {
// skw<"do"> simple (~ambig newline* ">" do_expr)+ // silent<"do"> simple (~ambig newline* ">" do_expr)+
// } // }
// Bind { // Bind {
// skw<"bind"> // silent<"bind">
// simple // simple
// (!pipeline pipeline)+ // (!pipeline pipeline)+
// } // }
@ -148,9 +148,9 @@ Struct_Pattern {
"}") "}")
} }
Let { skw<"let"> Pattern "=" non_binding } Let { silent<"let"> Pattern "=" non_binding }
Else { skw<"else"> } Else { silent<"else"> }
Match_Clause {(Pattern | Else) "->" newline* expression} Match_Clause {(Pattern | Else) "->" newline* expression}
@ -166,9 +166,9 @@ match_body {
} }
Match { Match {
skw<"match"> silent<"match">
simple simple
skw<"with"> silent<"with">
match_body match_body
} }
@ -177,7 +177,7 @@ When_Clause {
} }
When { When {
skw<"when"> "{" silent<"when"> "{"
terminator* terminator*
When_Clause (terminator+ When_Clause)* When_Clause (terminator+ When_Clause)*
terminator* terminator*
@ -185,16 +185,16 @@ When {
} }
If { If {
skw<"if"> simple newline* silent<"if"> simple newline*
skw<"then"> expression newline* silent<"then"> expression newline*
skw<"else"> expression silent<"else"> expression
} }
If_Let { If_Let {
skw<"if"> skw<"let"> silent<"if"> silent<"let">
Pattern "=" simple newline* Pattern "=" simple newline*
skw<"then"> expression newline* silent<"then"> expression newline*
skw<"else"> expression silent<"else"> expression
} }
Block { Block {
@ -268,15 +268,15 @@ Struct {
atom { Boolean | Nil | String | Number | Keyword | Word } atom { Boolean | Nil | String | Number | Keyword | Word }
kw<term> { @specialize[@name={term}]<Word, term> } keyword<term> { @specialize[@name={term}]<Word, term> }
skw<term> { @specialize<Word, term> } silent<term> { @specialize<Word, term> }
Keyword { ":" Word } Keyword { ":" Word }
Boolean { kw<"true"> | kw<"false"> } Boolean { keyword<"true"> | keyword<"false"> }
Nil { skw<"nil"> } Nil { silent<"nil"> }
@tokens { @tokens {
Word { $[a-z] $[a-zA-Z_\-?/!]* } Word { $[a-z] $[a-zA-Z_\-?/!]* }