finish port of model_syntax.ml