docs(spec): adopt RFC-LANG-0002 unified language semantics
Replace the Strong/Emph/List/Quote mapping in place with the single @exec/@knowledge heading-mode model, unified payload carriers and keyword control flow. - add the authoritative RFC, ADR-0052 and a historical ADR index - rewrite spec/mapping.md and spec/expression.ebnf as the normative mapping/statement grammar; update evaluation, references, math, foreign, package-format, plugin-abi, security and schema notes - rewrite README, AGENTS, COMPATIBILITY and CHANGELOG for the breaking language change; update the architecture index/overview and active docs - mark superseded planning docs, compute RFCs, evidence and syntax-role ADRs as historical/superseded without rewriting their decisions - add migration guide, per-file inventory and dev-only audit scripts The frontend/stdlib migration is completed in the following commits; this commit contains documentation only.
This commit is contained in:
1 parent
0d8ed44010
commit
49835424ee
47 files changed
+4941
-603
No files matched your search
+68
-16
@@ -1,23 +1,71 @@
|
||||
(* Marqdo Expression Grammar v1
|
||||
Status: frozen for M0.5, extended by ADR-0022 with Memory-index assignment
|
||||
targets. This is the only grammar for executable payloads.
|
||||
It is a small independent language: it is NOT Markdown and NOT translated
|
||||
to Python. Markdown AST decides where a payload exists; this grammar
|
||||
decides what it means.
|
||||
(* Marqdo Statement and Expression Grammar
|
||||
Status: current language contract, breaking rewrite (RFC-LANG-0002).
|
||||
This replaces the earlier v1 expression-only grammar in place.
|
||||
|
||||
Terminals are described in prose where Unicode categories matter.
|
||||
There is one grammar for every executable payload. Markdown AST decides
|
||||
which closed carrier (Strong / Emph / inline Code) is a payload and where
|
||||
it lives; this grammar decides what that payload means. No second parser
|
||||
and no per-file syntax selector exists.
|
||||
|
||||
Implementation state: the Rust expression parser still implements the
|
||||
previous, control-free grammar; this file is the target contract. See
|
||||
docs/STATUS.md.
|
||||
*)
|
||||
|
||||
program = [ statement ] , EOF ;
|
||||
(* One payload is exactly one statement and must consume the whole payload. *)
|
||||
payload = statement , EOF ;
|
||||
|
||||
statement = assignment | expression ;
|
||||
statement = if_stmt
|
||||
| else_stmt
|
||||
| while_stmt
|
||||
| end_stmt
|
||||
| return_stmt
|
||||
| params_stmt
|
||||
| assignment
|
||||
| expression ;
|
||||
|
||||
if_stmt = "if" , space_required , expression ;
|
||||
else_stmt = "else" ;
|
||||
while_stmt = "while" , space_required , expression ;
|
||||
end_stmt = "end" ;
|
||||
return_stmt = "return" , space_required , expression ;
|
||||
params_stmt = "params" , "(" , [ parameter_list ] , ")" ;
|
||||
|
||||
(* `if`, `else`, `while`, `end`, `return` and `params` are reserved statement
|
||||
words only when they are the complete first token of a payload.
|
||||
`ifdef(x)` and `returning(x)` are ordinary identifiers; a bare `if` used as
|
||||
an identifier is a reserved-word error. `else`/`end` take no additional
|
||||
tokens: `else x` and `end if` are syntax errors. No trailing colon:
|
||||
`if x > 0:` is a syntax error. No `elif`, `for`, `break`, `continue`,
|
||||
`try`, empty `return`, `end if`, or semicolon-separated multi-statement
|
||||
payload exists in this revision.
|
||||
|
||||
Control pairing is not part of this grammar; it is a separate compile-time
|
||||
stack in the frontend:
|
||||
- every `if` has exactly one closing `end`;
|
||||
- `else` is optional and at most one per `if`;
|
||||
- every `while` has exactly one closing `end`;
|
||||
- `else` must bind the top-of-stack `if`; `end` closes the top frame;
|
||||
- a frame must close inside the same heading's direct body.
|
||||
*)
|
||||
|
||||
(* Function parameter declaration. It is legal only as the first direct
|
||||
execution payload of an Exec H2 function, at most once, and never inside a
|
||||
list or block quote. The declaration is compile-time metadata, not a
|
||||
runtime call. *)
|
||||
parameter_list = parameter , { "," , parameter } , [ "," ] ;
|
||||
parameter = identifier , ":" , type_name , [ "=" , expression ] ;
|
||||
type_name = identifier ;
|
||||
(* Parameter names are unique; positional parameters precede defaulted ones.
|
||||
Types and default expressions reuse the existing signature rules. *)
|
||||
|
||||
(* Assignment and place writes are unchanged from the previous revision. *)
|
||||
assignment = assign_target , "=" , expression ;
|
||||
assign_target = identifier
|
||||
| postfix_expr , "[" , expression , "]" ;
|
||||
(* v1 left-hand sides are a local identifier or one index place. The index
|
||||
target writes one byte into an addressable Memory region; other base values
|
||||
are rejected at run time. Member assignment (`a.b = 1`) is a parse error.
|
||||
Chained assignment is a parse error. See ADR-0022. *)
|
||||
(* The index target writes one byte into an addressable Memory region; other
|
||||
base values are rejected at run time. Member assignment (`a.b = 1`) and
|
||||
chained assignment are parse errors. See ADR-0022. *)
|
||||
|
||||
expression = or_expr ;
|
||||
or_expr = and_expr , { "or" , and_expr } ;
|
||||
@@ -60,8 +108,9 @@ record_entry = ( identifier | text_literal ) , ":" , expression ;
|
||||
|
||||
identifier = xid_start , { xid_continue } ;
|
||||
(* Unicode XID per UAX #31: Chinese, Latin, etc. are valid.
|
||||
Keywords are reserved and cannot be identifiers:
|
||||
true, false, None, and, or, not. *)
|
||||
Reserved words cannot be identifiers:
|
||||
true, false, None, and, or, not,
|
||||
if, else, while, end, return, params. *)
|
||||
|
||||
int_literal = digit , { digit } ;
|
||||
(* arbitrary precision decimal integer; no sign here (unary
|
||||
@@ -77,7 +126,8 @@ escape = "\\" , ( '"' | "\\" | "n" | "t" | "r" | "u{" , hexdigit , { hex
|
||||
text_char = ? any Unicode scalar value except '"' and "\\" ? ;
|
||||
|
||||
(* Whitespace: any Unicode whitespace separates tokens. Newlines inside a
|
||||
code-span payload are whitespace. There are no comments in v1. *)
|
||||
code-span payload are whitespace. There are no comments. `space_required`
|
||||
means at least one whitespace character after the keyword. *)
|
||||
|
||||
(* Notes on the Markdown boundary *)
|
||||
(* - A "**" inside a payload is the power operator only when it survived
|
||||
@@ -88,3 +138,5 @@ text_char = ? any Unicode scalar value except '"' and "\\" ? ;
|
||||
payload; the frontend maps them back through the text/code segments to
|
||||
file spans. *)
|
||||
(* - Maximum nesting depth is 128; exceeding it is an expr.parse error. *)
|
||||
(* - Every payload must be fully consumed. A trailing token is a syntax error,
|
||||
never an ignored suffix. *)
|
||||
Reference in new issue
Block a user