« first day (759 days earlier)      last day (134 days later) » 

11:39 AM
@райтфолд How do you like my resolve function (line 8)? :)
lol already 100 views??
 
user1804599
12:00 PM
@FredOverflow You don't need it.
 
user1804599
All you need is Map since it's immutable anyway./
 
user1804599
The stack you use is then the call stack.
 
@райтфолд I don't have a call stack during parse.
 
user1804599
@FredOverflow How do you parse recursive structures?
 
@райтфолд Oh, you mean the runtime stack of the parser itself?
 
user1804599
12:09 PM
Yes.
 
user1804599
Often, when you need a stack, you can use the call stack instead.
 
Hm, let me ponder this idea for a while.
private def parseTypedef(): Symbol = {
  val symbol = if (currentToken.category == 'D') {
    nextToken()
    parseDeclaration().toTypeAlias
  } else {
    parseDeclaration()
  }
  symbols = symbols.add(symbol.name, symbol)
  println(symbols)
  symbol
}
When parseTypedef returns, wouldn't the "update" to the map be lost with your strategy?
 
user1804599
You add the symbol at the call-site.
 
It could probably work, but then I would have to pass the symbol table to every parse method... implicit parameters to the rescue? :)
 
user1804599
Yes that's what I do.
 
12:13 PM
Wait, how does the Map know about its surrounding scope? You need a reference to the enclosing scope, too. So just a Map is not enough.
 
user1804599
Or reader monad.
 
user1804599
@FredOverflow You don't.
 
user1804599
You add to the map.
 
user1804599
You don't create a new empty one.
 
How do you know whether you're allowed to add to the Map?
int a;
{
    int a;   // okay
    int a;   // error
}
 
user1804599
12:14 PM
Oh, I don't know.
 
user1804599
I don't have that problem.
 
user1804599
In that case you need a custom stack yes.
 
Although two Maps (currentScope, mungedTogetherEnclosingScopes) would be sufficient.
 
user1804599
let a = 2;
let a = a * a; // shadows first a
 
user1804599
This is what I do!
 
12:16 PM
feels REPLish
 
user1804599
It's good.
 
typedef int (*fp)(int x);
fp id(fp f);
int (*jd(int (*f)(int x)))(int y);
TypeAlias(fp,PointerType(FunctionType(List(Entity(x,IntType())),IntType())))
Entity(id,FunctionType(List(Entity(f,PointerType(FunctionType(List(Entity(x,IntType())),IntType())))),PointerType(FunctionType(List(Entity(x,IntType())),IntType()))))
Entity(jd,FunctionType(List(Entity(f,PointerType(FunctionType(List(Entity(x,IntType())),IntType())))),PointerType(FunctionType(List(Entity(y,IntType())),IntType()))))
All those closing parens almost make me want to learn Clojure.
@райтфолд lol WTF is this video
 

« first day (759 days earlier)      last day (134 days later) »