feat: implement M1 Ferro frontend

This commit is contained in:
2026-08-16 07:10:53 +09:00
parent 990068f424
commit 005056a5ea
32 changed files with 986 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
// ERROR:logical operator
unit old_logic;
fn main() { let x = true && false; }
+3
View File
@@ -0,0 +1,3 @@
// ERROR:expected ';'
unit broken;
fn main() { let x: i32 = 1 }
+3
View File
@@ -0,0 +1,3 @@
// ERROR:unterminated block comment
unit broken;
/* no ending delimiter
+25
View File
@@ -0,0 +1,25 @@
unit basic;
import core;
/* outer comment /* nested comment */ still active */
const LIMIT: u16 = 1_000;
pub struct Point {
pub x: i32,
y: i32,
pub fn new(x: i32, y: i32) -> Point { return Point{ x: x, y: y }; }
pub fn shift(self: &mut Self, dx: i32) { self.x += dx; }
}
pub enum Shape {
Empty,
Circle(i32),
Rect{ w: i32, h: i32 },
}
pub error IoError { NotFound = 1, Denied = 2, }
pub fn main() -> !void {
let p: Point = Point{ x: 1, y: 2 };
if p.x > 0 and true { p.shift(1); } else { p.x = 0; }
while p.x < 10 { p.x += 1; if p.x == 5 { continue; } }
for i, x in p.x..10 { let _n: usize = i; let _q = x; }
return;
}
+9
View File
@@ -0,0 +1,9 @@
unit keywords_and_builtins;
pub fn demo() {
let a = true and not false;
let b = a or false;
@print("selected branch");
let p = @as_far_fn(handler);
@call_far(p);
}
+12
View File
@@ -0,0 +1,12 @@
unit literals;
const A: u32 = 0xFF;
const B: u16 = 0b1010;
const C: u16 = 0o17;
const D: u32 = 1_000_000;
pub fn strings() {
let a = "hello\\nworld";
let b = '\x41';
let c = true;
let d = null;
let e = a orelse "fallback";
}
+20
View File
@@ -0,0 +1,20 @@
unit v012_forms;
shared atomic var ticks: u16 = 0;
packed struct Packet {
tag: u8,
value: u16,
}
interrupt_safe fn poll() { }
interrupt fn timer() { }
fn invoke(p: far fn()) { }
pub fn demo() {
var count = undefined;
count = 1;
critical { ticks += 1; }
let x = true and not false or false;
let y = x orelse true;
let e = error.NotFound;
@call_far(@as_far_fn(timer));
}
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
ok=0
for f in "$root"/std/*.fe; do
[ -f "$f" ] || continue
"$root"/fec --dump-ast "$f" >/dev/null || { echo "FAIL: $f"; exit 1; }
ok=$((ok+1))
done
for f in "$root"/tests/pass/*.fe; do
[ -f "$f" ] || continue
"$root"/fec --dump-ast "$f" >/dev/null || { echo "FAIL: $f"; exit 1; }
ok=$((ok+1))
done
for f in "$root"/tests/fail/*.fe; do
[ -f "$f" ] || continue
if "$root"/fec --dump-ast "$f" >/dev/null 2>/dev/null; then echo "FAIL (accepted): $f"; exit 1; fi
ok=$((ok+1))
done
echo "M1 tests: $ok cases passed"