Skip to content

Commit

Permalink
Try to fix collections.Iterable problem in fbuild.
Browse files Browse the repository at this point in the history
  • Loading branch information
skaller committed Dec 11, 2022
1 parent 93b4bc2 commit 3541781
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
6 changes: 5 additions & 1 deletion fbuild/lib/fbuild/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

import fbuild.fnmatch
import fbuild.glob
try:
collectionsIterable = collections.Iterable
except:
collectionsIterable = collections.abc.Iterable

# ------------------------------------------------------------------------------

Expand Down Expand Up @@ -527,7 +531,7 @@ def igloball(*patterns, **kwargs):
for pattern in patterns:
if \
not isinstance(pattern, str) and \
isinstance(pattern, collections.Iterable):
isinstance(pattern, collectionsIterable):
paths = Path.igloball(*pattern)
else:
paths = Path.glob(pattern, **kwargs)
Expand Down
49 changes: 47 additions & 2 deletions mfront.flx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,28 @@ binop_map.add "!=" " u32unchecked_neq\n";
unop_map.add "-" " u32unchecked_neg\n";
unop_map.add "!" " u32unchecked_not\n";

struct syminfo {
loc : int;
typ : string;
mut : bool;
}

struct symbol_table {
counter : int;
table: strdict[syminfo];
}

proc add(tab: &symbol_table) (key:string) (mut:bool) (typ:string) {
if tab->table.haskey key do
println$ "Duplicate symbol " + key;
System::exit(1);
else
var dat = syminfo (tab->counter, typ, mut);
tab->table.add key dat;
post_incr(tab.counter);
done
}

fun postfix: expr -> string =
| Const s => " push."+s+"\n"
| Ident s => "# push.loc."+s+"\n"
Expand Down Expand Up @@ -382,6 +404,7 @@ chip printer
{
var counter = 0;
var indent = 0;
var symtab = symbol_table(0, strdict[syminfo]());
while true do
++counter;
var line = read(io.inp);
Expand All @@ -391,12 +414,34 @@ chip printer
| Cons (head, tail) =>
if head in ("else", "end") if indent > 0 perform --indent;
if head == "eval" do
//println$ "EVAL ********************************";
//println$ "tokens = " + tail.str;
var e,rest = parse_expr tail;
println$ "# eval[inp] " + cat " " toks;
println$ "# eval[parsed] " e.str;
println$ e.postfix;
elif head == "let" do
var h = head;
var t = tail;
proc advance() {
match t with
| Cons(h1,t1) => h=h1; t = t1;
| _ => fail ("Incomplete let statement in:\n" + line);
endmatch;
}
advance;
var mut = false;
if h == "mut" do
mut = true;
advance;
done
var name = h; // check it's an identifier!
advance;
if h == "=" do
advance;
else
fail("Variable decl requires = symbol");
done
symtab&.add name mut "u32";
println$ "Added variable '" + name +"' to symbol table";
else
println$ " " * indent + cat "" toks;
done
Expand Down

0 comments on commit 3541781

Please sign in to comment.