Skip to content

Instantly share code, notes, and snippets.

@WimJongeneel
Last active January 2, 2020 08:20
Show Gist options
  • Save WimJongeneel/d1b37fdb19ea59875b9e34d447bbdc09 to your computer and use it in GitHub Desktop.
Save WimJongeneel/d1b37fdb19ea59875b9e34d447bbdc09 to your computer and use it in GitHub Desktop.
const compileOdata = (e: Expr): string => {
if (e.kind == 'acs') return e.id.toString()
if (e.kind == '==') return `${compileOdata(e.left)} eq ${compileOdata(e.right)}`
if (e.kind == 'includes') return `substringof( ${compileOdata(e.right)}, ${compileOdata(e.left)})`
if (e.kind == '&&') return `${compileOdata(e.left)} and ${compileOdata(e.right)}`
if (e.kind == 'val') return typeof e.value == 'string' ? `'${e.value}'` : e.value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment