@muten/core 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/grammar/muten.gbnf +105 -0
- package/package.json +6 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# muten.gbnf — GENERATED from @muten/core by scripts/gen-gbnf.mjs. DO NOT EDIT BY HAND.
|
|
2
|
+
# A constrained-decoding grammar for ONE screen/page. Covers screen/state/store/const/get/entity/
|
|
3
|
+
# meta/use/param/action + the node tree + expressions. (app.muten: routes/shell/api/sources/theme/part
|
|
4
|
+
# are a separate file — out of scope for v1.)
|
|
5
|
+
|
|
6
|
+
root ::= ws "screen" sp ident ws decls node ws
|
|
7
|
+
|
|
8
|
+
decls ::= (decl ws)*
|
|
9
|
+
decl ::= use-decl | param-decl | const-decl | entity-decl | state-decl | store-decl | get-decl | meta-decl | action-decl
|
|
10
|
+
|
|
11
|
+
use-decl ::= "use" sp ident (ws "," ws ident)* sp "from" sp string
|
|
12
|
+
param-decl ::= "param" sp ident
|
|
13
|
+
const-decl ::= "const" sp ident ws "=" ws scalar
|
|
14
|
+
entity-decl ::= "entity" sp ident ws "{" ws (field ws)* "}"
|
|
15
|
+
field ::= ident sp ident (ws "|" ws ident)* (sp constraint)*
|
|
16
|
+
constraint ::= "required" | ("min" | "max") ws ":" ws number
|
|
17
|
+
state-decl ::= "state" ws "{" ws (statevar ws)* "}"
|
|
18
|
+
store-decl ::= "store" ws "{" ws (statevar ws)* "}"
|
|
19
|
+
statevar ::= ident ws "=" ws stateinit ws ":" ws type
|
|
20
|
+
stateinit ::= "query" sp ident | value
|
|
21
|
+
type ::= ident ("<" ident ">")?
|
|
22
|
+
get-decl ::= "get" sp ident ws "=" ws expr
|
|
23
|
+
meta-decl ::= "meta" ws "{" ws (ident sp string ws)* "}"
|
|
24
|
+
action-decl ::= "action" sp ident mutates? input? ws actionbody
|
|
25
|
+
mutates ::= sp "mutates" sp ident (ws "," ws ident)*
|
|
26
|
+
input ::= ws "<-" ws ident
|
|
27
|
+
actionbody ::= "{" ws (stmt ws)* "}"
|
|
28
|
+
stmt ::= ifstmt | requeststmt | callstmt
|
|
29
|
+
ifstmt ::= "if" sp expr ws actionbody (ws "else" ws actionbody)?
|
|
30
|
+
requeststmt ::= ("post" | "put" | "delete") sp string (sp "body" sp expr)?
|
|
31
|
+
callstmt ::= ident "." actionop "(" ws callargs ws ")"
|
|
32
|
+
actionop ::= "push" | "remove" | "reset" | "set" | "create" | "update" | "delete" | "refetch"
|
|
33
|
+
callargs ::= refetcharg (ws "," ws refetcharg)* | predarg | expr | ""
|
|
34
|
+
refetcharg ::= ident ws ":" ws expr
|
|
35
|
+
predarg ::= ident ws "=>" ws expr
|
|
36
|
+
|
|
37
|
+
node ::= whennode | eachnode | linknode | actionnode | customnode | plainnode
|
|
38
|
+
whennode ::= "when" sp expr ws block
|
|
39
|
+
eachnode ::= "each" sp expr sp "as" sp ident ws block
|
|
40
|
+
block ::= "{" ws (node ws)* "}"
|
|
41
|
+
linknode ::= "Link" (sp (commonpart | "->" ws path))* (ws block)?
|
|
42
|
+
actionnode ::= ("RowAction" | "Button") (sp (commonpart | actionarrow))* (ws block)?
|
|
43
|
+
actionarrow ::= "->" ws dotted (ws "(" ws expr? ws ")")?
|
|
44
|
+
customnode ::= "Custom" sp ident (sp modifier)*
|
|
45
|
+
plainnode ::= ("Stack" | "Header" | "Nav" | "Sidebar" | "Footer" | "Page" | "Text" | "Title" | "Span" | "Image" | "SearchField" | "DataTable" | "Form" | "slot") (sp commonpart)* (ws block)?
|
|
46
|
+
commonpart ::= string | ref | level | modifier
|
|
47
|
+
level ::= "h" [1-6]
|
|
48
|
+
|
|
49
|
+
modifier ::= stylemod | classmod | bindmod | submitmod | wheremod | columnsmod | altmod | inputsmod | onmod
|
|
50
|
+
stylemod ::= "style" ws "(" ws styletoken (ws "," ws styletoken)* ws ")"
|
|
51
|
+
classmod ::= "class" ws "(" ws classitem (ws "," ws classitem)* ws ")"
|
|
52
|
+
classitem ::= (string | ident) (sp "when" sp expr)?
|
|
53
|
+
bindmod ::= "bind" sp (ref | dotted)
|
|
54
|
+
submitmod ::= "submit" sp dotted
|
|
55
|
+
wheremod ::= "where" ws "(" ws clause (ws "," ws clause)* ws ")"
|
|
56
|
+
clause ::= dotted ws cmpop ws (ref | value)
|
|
57
|
+
columnsmod ::= "columns" ws "(" ws ident (ws "," ws ident)* ws ")"
|
|
58
|
+
altmod ::= "alt" sp string
|
|
59
|
+
inputsmod ::= "inputs" ws "(" ws argpairs ws ")"
|
|
60
|
+
onmod ::= "on" ws "(" ws argpairs ws ")"
|
|
61
|
+
argpairs ::= argpair (ws "," ws argpair)*
|
|
62
|
+
argpair ::= ident ws ":" ws argval
|
|
63
|
+
argval ::= string | number | ref | dotted
|
|
64
|
+
|
|
65
|
+
styletoken ::= (breakpoint ":")? (atom | family "." tokenmod)
|
|
66
|
+
breakpoint ::= "sm" | "md" | "lg" | "xl"
|
|
67
|
+
atom ::= "row" | "column" | "wrap" | "grid" | "grow" | "center" | "between" | "bold" | "italic"
|
|
68
|
+
family ::= "gap" | "padding" | "margin" | "cols" | "rows" | "text" | "weight" | "leading" | "align" | "justify" | "items" | "width" | "height"
|
|
69
|
+
tokenmod ::= ("x." | "y.")? scaleseg
|
|
70
|
+
scaleseg ::= ident | number
|
|
71
|
+
|
|
72
|
+
path ::= ("/" pathseg?)+
|
|
73
|
+
pathseg ::= ident | "{" ws expr ws "}"
|
|
74
|
+
|
|
75
|
+
# expressions — the parser's precedence ladder (no left recursion: iterate, don't self-reference first)
|
|
76
|
+
expr ::= ternary
|
|
77
|
+
ternary ::= orexpr (ws "?" ws ternary ws ":" ws ternary)?
|
|
78
|
+
orexpr ::= andexpr (sp "or" sp andexpr)*
|
|
79
|
+
andexpr ::= cmpexpr (sp "and" sp cmpexpr)*
|
|
80
|
+
cmpexpr ::= addexpr (ws cmpop ws addexpr)*
|
|
81
|
+
cmpop ::= "==" | "!=" | "<=" | ">=" | "<" | ">" | "contains"
|
|
82
|
+
addexpr ::= mulexpr (ws ("+" | "-") ws mulexpr)*
|
|
83
|
+
mulexpr ::= unary (ws ("*" | "/") ws unary)*
|
|
84
|
+
unary ::= ("not" sp)? primary
|
|
85
|
+
primary ::= "(" ws ternary ws ")" | string | number | bool | "null" | callorref
|
|
86
|
+
callorref ::= dotted (ws "(" ws (ternary (ws "," ws ternary)*)? ws ")")?
|
|
87
|
+
|
|
88
|
+
value ::= array | object | scalar
|
|
89
|
+
array ::= "[" ws (value (ws "," ws value)*)? ws "]"
|
|
90
|
+
object ::= "{" ws (objpair (ws "," ws objpair)*)? ws "}"
|
|
91
|
+
objpair ::= (ident | string) ws ":" ws value
|
|
92
|
+
scalar ::= string | number | bool | "null" | ident
|
|
93
|
+
|
|
94
|
+
bool ::= "true" | "false"
|
|
95
|
+
ref ::= "@" ident ("." ident)*
|
|
96
|
+
dotted ::= "$"? ident ("." ident)*
|
|
97
|
+
ident ::= [a-zA-Z_] [a-zA-Z0-9_]*
|
|
98
|
+
number ::= [0-9]+ ("." [0-9]+)?
|
|
99
|
+
string ::= "\"" [^"]* "\""
|
|
100
|
+
|
|
101
|
+
# whitespace — NO comments in the generation grammar on purpose: a weak model degenerates into
|
|
102
|
+
# comment spam (free whitespace) and never closes the page. Humans add comments by hand after.
|
|
103
|
+
ws ::= wschar*
|
|
104
|
+
sp ::= wschar+
|
|
105
|
+
wschar ::= [ \t\r\n]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muten/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "AI-first frontend framework — compiles .muten files to vanilla JS + signals.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
26
|
"spec",
|
|
27
|
+
"grammar",
|
|
27
28
|
"README.md",
|
|
28
29
|
"LICENSE"
|
|
29
30
|
],
|
|
@@ -41,8 +42,9 @@
|
|
|
41
42
|
"license": "MIT",
|
|
42
43
|
"scripts": {
|
|
43
44
|
"prepare": "npm run build",
|
|
44
|
-
"build": "tsc && node --experimental-strip-types esbuild.ts",
|
|
45
|
-
"
|
|
45
|
+
"build": "tsc && node --experimental-strip-types esbuild.ts && node scripts/gen-gbnf.mjs",
|
|
46
|
+
"gbnf": "node scripts/gen-gbnf.mjs",
|
|
47
|
+
"test": "npm run build && node --experimental-strip-types test/parse.ts && node --experimental-strip-types test/expr.ts && node --experimental-strip-types test/parts.ts && node --experimental-strip-types test/diagnostics.ts && node --experimental-strip-types test/routes.ts && node --experimental-strip-types test/params.ts && node --experimental-strip-types test/ssr.ts && node --experimental-strip-types test/writes.ts && node --experimental-strip-types test/dynamics.ts && node --experimental-strip-types test/runtime.ts && node --experimental-strip-types test/lang.ts && node --experimental-strip-types test/forms.ts && node --experimental-strip-types test/smoke.ts && node --experimental-strip-types test/print.ts && node --experimental-strip-types test/externs.ts && node --experimental-strip-types test/islands.ts && node test/gbnf.mjs"
|
|
46
48
|
},
|
|
47
49
|
"optionalDependencies": {
|
|
48
50
|
"sass": "^1.101.0"
|
|
@@ -50,6 +52,7 @@
|
|
|
50
52
|
"devDependencies": {
|
|
51
53
|
"@types/node": "^26.0.0",
|
|
52
54
|
"esbuild": "^0.28.1",
|
|
55
|
+
"gbnf": "^0.1.41",
|
|
53
56
|
"typescript": "^6.0.3",
|
|
54
57
|
"vite": "^8.0.16"
|
|
55
58
|
}
|