open Component module Term = HOTerm module Judgment = HOTerm module Ports = Ports(Term, Judgment) type state = {grammar: MixfixGrammar.grammar, compiled: MixfixGrammar.compiled} type props = { content: state, imports: Ports.t, onChange: (state, ~exports: Ports.t=?) => unit, reset: unit => unit, } let serialise = (s, ~imports as _: Ports.t) => MixfixGrammar.prettyPrintGrammar(s.grammar) let deserialise = (input: string, ~imports as _: Ports.t) => switch MixfixGrammar.parseDecls(String.trim(input)) { | Ok((grammar, "")) => switch MixfixGrammar.compile(grammar) { | Ok(compiled) => Ok(({grammar, compiled}, {Ports.facts: Dict.make(), ruleStyle: None, grammar: compiled})) | Error(s) => Error(s) } | Error(s) => Error(s) | Ok((_, s)) => Error("Unable to read from: " ++ s) } module AssocBadge = { @react.component let make = (~assoc: MixfixGrammar.assoc) => { let (label, cls) = switch assoc { | Left => ("infixl", "assoc-left") | Right => ("infixr", "assoc-right") | NonAssoc => ("infix", "assoc-none") } {React.string(label)} } } module OpRow = { @react.component let make = (~op: MixfixGrammar.opDecl) =>