diprism / perpl

The PERPL Compiler
MIT License
10 stars 5 forks source link

extern #27

Closed davidweichiang closed 2 years ago

davidweichiang commented 2 years ago

It seems like extern declarations are currently compiled to a factor with all zero weights. For example

extern coin : Bool;
coin

has a nonterminal coin that rewrites to a factor 0 with all zero weights. Is that right? What's the reason for the separation between coin and 0?

Should we extend the FGG file format to have external nonterminals or factors, to make explicit that it was declared extern?

colin-mcd commented 2 years ago

Originally, it was coin that was a factor with all zero weights. To match code/example12.json though, coin needed to be a nonterminal. I think I probably just added the zero weights factor 0 to allow me to actually set the extern weights in the json and try running it for debugging purposes.

Are you thinking that the FGG file should have "domains", "factors", "nonterminals", "rules", and "externs"?

davidweichiang commented 2 years ago

I'm thinking that it can be a factor, but its function is "extern" instead of "categorical"? Like this:

{
  "function": "extern",
  "type": ...
}
davidweichiang commented 2 years ago

35 shows what this would look like.

davidweichiang commented 2 years ago

I think that looks good; then I'll have to modify the FGG side to handle those incomplete factors.