disallow '.' as mapsTo token (only ↦ now)
Intention is to reuse the '.' token as namespace delimiter and '::' to be used as return type prefix instead
This commit is contained in:
parent
312e97193a
commit
b336f2f847
3 changed files with 26 additions and 27 deletions
|
@ -8,7 +8,7 @@ pub enum LTIRToken {
|
||||||
// DoubleQuote(String),
|
// DoubleQuote(String),
|
||||||
// TripleQuote(String),
|
// TripleQuote(String),
|
||||||
Lambda,
|
Lambda,
|
||||||
LambdaBody,
|
MapsTo,
|
||||||
AssignType(String),
|
AssignType(String),
|
||||||
AssignValue,
|
AssignValue,
|
||||||
|
|
||||||
|
@ -115,11 +115,11 @@ where
|
||||||
region.end += 1;
|
region.end += 1;
|
||||||
return Some((region, Ok(LTIRToken::Lambda)));
|
return Some((region, Ok(LTIRToken::Lambda)));
|
||||||
}
|
}
|
||||||
'.' | '↦' => {
|
'↦' => {
|
||||||
self.chars.next();
|
self.chars.next();
|
||||||
self.position += 1;
|
self.position += 1;
|
||||||
region.end += 1;
|
region.end += 1;
|
||||||
return Some((region, Ok(LTIRToken::LambdaBody)));
|
return Some((region, Ok(LTIRToken::MapsTo)));
|
||||||
}
|
}
|
||||||
'(' => {
|
'(' => {
|
||||||
self.chars.next();
|
self.chars.next();
|
||||||
|
@ -219,7 +219,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerState::TypeTerm(s) => {
|
LexerState::TypeTerm(s) => {
|
||||||
if *c == '=' || *c == '.' || *c == '↦' || *c == ';' {
|
if *c == '=' || *c == '↦' || *c == ';' {
|
||||||
if let Some(token) = state.clone().into_token() {
|
if let Some(token) = state.clone().into_token() {
|
||||||
return Some((region, Ok(token)));
|
return Some((region, Ok(token)));
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,6 @@ where
|
||||||
|| *c == ';'
|
|| *c == ';'
|
||||||
|| *c == '='
|
|| *c == '='
|
||||||
|| *c == ':'
|
|| *c == ':'
|
||||||
|| *c == '.'
|
|
||||||
|| *c == '↦'
|
|| *c == '↦'
|
||||||
{
|
{
|
||||||
// finish the current token
|
// finish the current token
|
||||||
|
|
42
src/main.rs
42
src/main.rs
|
@ -62,8 +62,8 @@ fn main() {
|
||||||
"main",
|
"main",
|
||||||
"{
|
"{
|
||||||
let print-nullterm =
|
let print-nullterm =
|
||||||
λ{} : < Seq Char~Ascii~machine::Word >
|
λ{} : < Seq Char ~Ascii ~ machine.Word >
|
||||||
~ < NullTerminatedArray machine::Word >
|
~ < NullTerminatedArray machine.Word >
|
||||||
↦ {
|
↦ {
|
||||||
while(dup) { emit; }
|
while(dup) { emit; }
|
||||||
drop;
|
drop;
|
||||||
|
@ -72,7 +72,7 @@ fn main() {
|
||||||
print-nullterm 'H' 'a' 'l' 'l' 'o' ' ' 'W' 'e' 'l' 't' '!' '\n' '\0';
|
print-nullterm 'H' 'a' 'l' 'l' 'o' ' ' 'W' 'e' 'l' 't' '!' '\n' '\0';
|
||||||
|
|
||||||
let fmt-uint =
|
let fmt-uint =
|
||||||
λx : ℕ ~ ℤ_2^64 ~ machine::UInt64
|
λx : ℕ ~ ℤ_2^64 ~ machine.UInt64
|
||||||
↦ {
|
↦ {
|
||||||
if( x ) {
|
if( x ) {
|
||||||
while( x ) {
|
while( x ) {
|
||||||
|
@ -86,40 +86,40 @@ fn main() {
|
||||||
|
|
||||||
let print-uint = λx:ℕ ↦ print-nullterm (fmt-uint x) '\0';
|
let print-uint = λx:ℕ ↦ print-nullterm (fmt-uint x) '\0';
|
||||||
|
|
||||||
let int-neg = λx : ℤ~machine::Int64~machine::Word ↦ i+ (bit-neg x) 1;
|
let int-neg = λx : ℤ ~ machine.Int64 ~ machine.Word ↦ i+ (bit-neg x) 1;
|
||||||
let int-sign = λx : ℤ~machine::Int64~machine::Word ↦ bit-and (bit-shr x 63) 1;
|
let int-sign = λx : ℤ ~ machine.Int64 ~ machine.Word ↦ bit-and (bit-shr x 63) 1;
|
||||||
|
|
||||||
let int-lt = λ{
|
let int-lt = λ{
|
||||||
a : ℤ ~ machine::Int64;
|
a : ℤ ~ machine.Int64;
|
||||||
b : ℤ ~ machine::Int64;
|
b : ℤ ~ machine.Int64;
|
||||||
} ↦ int-sign (i- a b);
|
} ↦ int-sign (i- a b);
|
||||||
|
|
||||||
let int-gt = λ{
|
let int-gt = λ{
|
||||||
a : ℤ ~ machine::Int64;
|
a : ℤ ~ machine.Int64;
|
||||||
b : ℤ ~ machine::Int64;
|
b : ℤ ~ machine.Int64;
|
||||||
} ↦ int-sign (i- b a);
|
} ↦ int-sign (i- b a);
|
||||||
|
|
||||||
let int-eq = λ{
|
let int-eq = λ{
|
||||||
a : ℤ ~ machine::Int64;
|
a : ℤ ~ machine.Int64;
|
||||||
b : ℤ ~ machine::Int64;
|
b : ℤ ~ machine.Int64;
|
||||||
} ↦ if (i- a b) { 0; } else { 1; };
|
} ↦ if (i- a b) { 0; } else { 1; };
|
||||||
|
|
||||||
let int-lte = λa:ℤ.λb:ℤ ↦ bit-or (int-lt a b) (int-eq a b);
|
let int-lte = λa:ℤ ↦ λb:ℤ ↦ bit-or (int-lt a b) (int-eq a b);
|
||||||
let int-gte = λa:ℤ.λb:ℤ ↦ bit-or (int-gt a b) (int-eq a b);
|
let int-gte = λa:ℤ ↦ λb:ℤ ↦ bit-or (int-gt a b) (int-eq a b);
|
||||||
|
|
||||||
let int-min = λ{
|
let int-min = λ{
|
||||||
a : ℤ ~ machine::Int64;
|
a : ℤ ~ machine.Int64;
|
||||||
b : ℤ ~ machine::Int64;
|
b : ℤ ~ machine.Int64;
|
||||||
} ↦ if( int-lt a b ) { a; } else { b; };
|
} ↦ if( int-lt a b ) { a; } else { b; };
|
||||||
|
|
||||||
let int-max = λ{
|
let int-max = λ{
|
||||||
a : ℤ ~ machine::Int64;
|
a : ℤ ~ machine.Int64;
|
||||||
b : ℤ ~ machine::Int64;
|
b : ℤ ~ machine.Int64;
|
||||||
} ↦ if( int-gt a b ) { a; } else { b; };
|
} ↦ if( int-gt a b ) { a; } else { b; };
|
||||||
|
|
||||||
let vec3i-add = λ{
|
let vec3i-add = λ{
|
||||||
{ ax:ℤ_2^64; ay:ℤ_2^64; az:ℤ_2^64; } : <Vec3 ℤ_2^64~machine::UInt64>;
|
{ ax:ℤ_2^64; ay:ℤ_2^64; az:ℤ_2^64; } : <Vec3 ℤ_2^64~machine.UInt64>;
|
||||||
{ bx:ℤ_2^64; by:ℤ_2^64; bz:ℤ_2^64; } : <Vec3 ℤ_2^64~machine::UInt64>;
|
{ bx:ℤ_2^64; by:ℤ_2^64; bz:ℤ_2^64; } : <Vec3 ℤ_2^64~machine.UInt64>;
|
||||||
} ↦ {
|
} ↦ {
|
||||||
i+ az bz;
|
i+ az bz;
|
||||||
i+ ay by;
|
i+ ay by;
|
||||||
|
@ -127,7 +127,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let fmt-vec3i =
|
let fmt-vec3i =
|
||||||
λ{ x:ℤ_2^64; y:ℤ_2^64; z:ℤ_2^64; } : <Vec3 ℤ_2^64~machine::UInt64>
|
λ{ x:ℤ_2^64; y:ℤ_2^64; z:ℤ_2^64; } : <Vec3 ℤ_2^64~machine.UInt64>
|
||||||
↦ {
|
↦ {
|
||||||
'}';
|
'}';
|
||||||
fmt-uint z; '='; 'z'; ' '; ';';
|
fmt-uint z; '='; 'z'; ' '; ';';
|
||||||
|
@ -136,7 +136,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let red-u8rgb
|
let red-u8rgb
|
||||||
: <Fn <> Color ~ RGB ~ <Vec3 ℝ_0,1 ~ ℤ_256 ~ machine::UInt64>>
|
: <Fn <> Color ~ RGB ~ <Vec3 ℝ_0,1 ~ ℤ_256 ~ machine.UInt64>>
|
||||||
= λ{} ↦ { 0; 0; 255; };
|
= λ{} ↦ { 0; 0; 255; };
|
||||||
let green-u8rgb = λ{} ↦ { 0; 255; 0; };
|
let green-u8rgb = λ{} ↦ { 0; 255; 0; };
|
||||||
let blue-u8rgb = λ{} ↦ { 255; 0; 0; };
|
let blue-u8rgb = λ{} ↦ { 255; 0; 0; };
|
||||||
|
|
|
@ -309,7 +309,7 @@ where
|
||||||
tokens.next();
|
tokens.next();
|
||||||
|
|
||||||
let mut variable_bindings = parse_binding_expr(typectx, tokens)?;
|
let mut variable_bindings = parse_binding_expr(typectx, tokens)?;
|
||||||
let _ = parse_expect(tokens, LTIRToken::LambdaBody);
|
let _ = parse_expect(tokens, LTIRToken::MapsTo);
|
||||||
let body = parse_expr(typectx, tokens)?;
|
let body = parse_expr(typectx, tokens)?;
|
||||||
|
|
||||||
return Ok(LTExpr::Abstraction {
|
return Ok(LTExpr::Abstraction {
|
||||||
|
|
Loading…
Reference in a new issue