Skip to content

Instantly share code, notes, and snippets.

@backupbrain
Last active October 15, 2018 21:49
Show Gist options
  • Save backupbrain/0c4b1cfbdb5fcaa4abb7d6ca717a845d to your computer and use it in GitHub Desktop.
Save backupbrain/0c4b1cfbdb5fcaa4abb7d6ca717a845d to your computer and use it in GitHub Desktop.
function LexicalAnalyzer() {
this.tokenTypes = {
"include": /^include$/,
"string": /^\"[^\"]+\"$/,
"unaryop": /^(sin|cos|tan|exp|ln|sqrt)$/,
"exp": /^(\+|\-|\*|\/|\^)$/,
"comma": /^\,$/,
"openparen": /^\($/,
"closeparen": /^\)$/,
"openbracket": /^\[$/,
"closebracket": /^\]$/,
"openfunction": /^\{$/,
"closefunction": /^\}$/,
"uop": /^(U|CX)$/,
"qop": /^(measure|reset)$/,
"pointer": /^\-\>$/,
"gop": /^barrier$/,
"gatedecl": /gate/,
"decl": /^(qreg|creg)$/,
"control": /^if$/,
"condition": /^(\=\=|\!\=)$/,
"statement": /^(opaque)$/,
"mainprogram": /^OPENQASM$/,
"id": /^[a-z][A-Za-z0-9_]*$/,
"const": /^pi$/,
"eol": /^\;$/,
"id": /^[a-z][A-Za-z0-9_]*$/,
"real": /^([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([eE][-+]?[0-9]+)?$/,
"nninteger": /^[1-9]+[0-9]*|0$/,
"var": /^[\a-zA-Z]+[a-zA-Z0-9\_]*$/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment