{ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "name": "OpenQASM", "scopeName": "source.openqasm", "fileTypes": [ "qasm" ], "patterns": [ { "include": "#comments" }, { "include": "#directives" }, { "include": "#definitions" }, { "include": "#strings" }, { "include": "#numbers" }, { "include": "#keywords" }, { "include": "#types" }, { "include": "#constants" }, { "include": "#functions" }, { "include": "#gates" }, { "include": "#calls" }, { "include": "#hardware" }, { "include": "#operators" }, { "include": "#punctuation" } ], "repository": { "comments": { "patterns": [ { "name": "comment.line.double-slash.openqasm", "match": "//.*$" }, { "name": "comment.block.openqasm", "begin": "/\\*", "end": "\\*/" } ] }, "directives": { "patterns": [ { "name": "meta.preprocessor.pragma.openqasm", "match": "^\\s*(#?pragma)\\b.*$", "captures": { "1": { "name": "keyword.control.directive.pragma.openqasm" } } }, { "name": "meta.annotation.openqasm", "match": "^\\s*(@[A-Za-z_][\\w.]*).*$", "captures": { "1": { "name": "storage.type.annotation.openqasm" } } }, { "match": "\\b(OPENQASM)\\s+([0-9]+(?:\\.[0-9]+)?)", "captures": { "1": { "name": "keyword.control.directive.version.openqasm" }, "2": { "name": "constant.numeric.version.openqasm" } } }, { "name": "keyword.control.import.openqasm", "match": "\\b(?:include|defcalgrammar)\\b" } ] }, "definitions": { "patterns": [ { "match": "\\b(gate|opaque)\\s+([\\p{L}_][\\p{L}\\p{N}_]*)", "captures": { "1": { "name": "storage.type.gate.openqasm" }, "2": { "name": "entity.name.function.gate.openqasm" } } }, { "match": "\\b(def|extern)\\s+([\\p{L}_][\\p{L}\\p{N}_]*)", "captures": { "1": { "name": "storage.type.function.openqasm" }, "2": { "name": "entity.name.function.openqasm" } } }, { "match": "\\b(defcal)\\s+([\\p{L}_][\\p{L}\\p{N}_]*)", "captures": { "1": { "name": "storage.type.calibration.openqasm" }, "2": { "name": "entity.name.function.calibration.openqasm" } } }, { "name": "storage.type.calibration.openqasm", "match": "\\bcal\\b(?=\\s*\\{)" } ] }, "strings": { "patterns": [ { "name": "string.quoted.double.openqasm", "begin": "\"", "end": "\"|$" }, { "name": "string.quoted.single.openqasm", "begin": "'", "end": "'|$" } ] }, "numbers": { "patterns": [ { "name": "constant.numeric.duration.openqasm", "match": "(?|\\+\\+|\\*\\*=?|<<=?|>>=?|==|!=|<=|>=|&&|\\|\\||[-+*/%&|^~]=|[-+*/%=<>!~&|^@]" } ] }, "punctuation": { "patterns": [ { "name": "punctuation.terminator.statement.openqasm", "match": ";" }, { "name": "punctuation.separator.comma.openqasm", "match": "," }, { "name": "punctuation.separator.range.openqasm", "match": ":" } ] } } }