{
	"scopeName": "source.cfa",
	"patterns": [
		{ "include": "#comment"},
		{ "include": "#preprocessor"},
		{ "include": "#extern"},
		{ "include": "#declaration"},
		{ "include": "#constant"},
		{ "include": "#statement"},
		{ "include": "#operator"}
	],
	"repository": {
		"preprocessor": {
			"patterns":[
				{ "include": "#directive.pragma" },
				{ "include": "#directive.include" },
				{ "include": "#directive.define" },
				{ "include": "#directive.undef" },
				{ "include": "#directive.ifdef" },
				{ "include": "#directive.condition.arg" },
				{ "include": "#directive.condition.noargs" }
			],
			"repository": {
				"directive.punctuation": {
					"match": "#",
					"name": "punctuation.definition.directive.cfa"
				},
				"directive.pragma": {
					"name": "meta.preprocessor.pragma.cfa",
					"match": "^\\s*(#\\s*pragma)\\s+(((?!//|/\\*).)*)",
					"captures":{
						"1": {
							"name": "keyword.control.directive.pragma.cfa",
							"patterns":[{ "include": "#directive.punctuation"} ]
						},
						"2": {"name": "keyword.control.directive.pragma.argument.cfa"}
					}
				},
				"directive.include.string": {
					"begin": "<|\"",
					"end": ">|\"",
					"beginCaptures": {
						"0": { "name": "punctuation.definition.string.begin.cfa" }
					},
					"endCaptures": {
						"0": { "name": "punctuation.definition.string.end.cfa" }
					},
					"name": "string.quoted.include.cfa"
				},
				"directive.include": {
					"name": "meta.preprocessor.include.cfa",
					"match": "^\\s*(#\\s*include)\\s+(<.*>|\".*\")",
					"captures": {
						"1": {
							"name": "keyword.control.directive.include.cfa",
							"patterns":[{ "include": "#directive.punctuation"} ]
						},
						"2": {"patterns": [{ "include": "#directive.include.string"}]}
					}
				},
				"directive.macro.name": {
					"name": "entity.name.function.preprocessor.cfa",
					"match": "[A-z0-9_]+"
				},
				"directive.define": {
					"name": "meta.preprocessor.macro.cfa",
					"match": "(#\\s*define)\\s+([A-z0-9_]+)(\\(.*\\))?\\s+(.*)?",
					"captures": {
						"1": {
							"name": "keyword.control.directive.define.cfa",
							"patterns":[{ "include": "#directive.punctuation"} ]
						},
						"2": {"patterns": [{ "include": "#directive.macro.name"}]},
						"3": {"name":"meta.preprocessor.macro.args.cfa"},
						"4": {"name":"meta.preprocessor.macro.definition.cfa", "patterns": [{ "include": "$self" }]}
					}
				},
				"directive.undef": {
					"name": "meta.preprocessor.macro.cfa",
					"match": "^\\s*(#\\s*undef)\\s+(\\w+)",
					"captures": {
						"1": {
							"name": "keyword.control.directive.undef.cfa",
							"patterns":[{ "include": "#directive.punctuation"} ]
						},
						"2": {"name":"meta.define.B", "patterns": [{ "include": "#directive.macro.name"}]}
					}
				},
				"directive.isdef": {
					"match": "(defined)\\s*\\(\\s*(\\w+)\\s*\\)",
					"captures": {
						"1": {
							"name": "keyword.control.directive.conditional.cfa",
							"match": "defined"
						},
						"2": {"patterns": [{ "include": "#directive.macro.name"}]}
					}
				},
				"directive.ifdef": {
					"name": "meta.preprocessor.cfa",
					"match": "^\\s*(#\\s*ifdef)\\s+(\\w+)",
					"captures": {
						"1": {
							"name": "keyword.control.directive.conditional.cfa",
							"patterns":[{ "include": "#directive.punctuation"} ]
						},
						"2": {"patterns": [{ "include": "#directive.macro.name"}]}
					}
				},
				"directive.condition.arg": {
					"name": "meta.preprocessor.cfa",
					"match": "^\\s*(#\\s*if|#\\s*elif)\\s+(.*)",
					"captures": {
						"1": {
							"name": "keyword.control.directive.conditional.cfa",
							"patterns":[{ "include": "#directive.punctuation"} ]
						},
						"2": {"patterns":[
							{ "include": "#expression"},
							{ "include": "#directive.isdef"}
						]}
					}
				},
				"directive.condition.noargs": {
					"name": "meta.preprocessor.cfa",
					"match": "^\\s*(#\\s*endif|#\\s*else)\\s+",
					"captures": {
						"1": {
							"name": "keyword.control.directive.conditional.cfa",
							"patterns":[{ "include": "#directive.punctuation"} ]
						}
					}
				}
			}
		},
		"comment": {
			"patterns":[
				{ "include": "#comments.line"},
				{ "include": "#comments.block"}
			],
			"repository": {
				"comments.line":{
					"name": "comment.line.double-slash.cfa",
					"match": "(\/\/).*",
					"captures": {
						"1": {"name": "punctuation.definition.comment.c", "match": "\/\/"}
					}
				},
				"comments.block":{
					"name": "comment.block.cfa",
					"begin": "/\\*",
					"end": "\\*/",
					"beginCaptures": {
						"0": { "name": "punctuation.definition.comment.begin.cfa" }
					},
					"endCaptures": {
						"0": { "name": "punctuation.definition.comment.end.cfa" }
					}
				}
			}
		},
		"extern": {
			"patterns": [{ "include": "#extern.block"}],
			"repository": {
				"extern.head.string": {
					"begin": "\"",
					"end": "\"",
					"beginCaptures": {
						"0": { "name": "punctuation.definition.string.begin.cfa" }
					},
					"endCaptures": {
						"0": { "name": "punctuation.definition.string.end.cfa" }
					},
					"name": "string.quoted.extern.cfa"
				},
				"extern.head": {
					"match": "(extern)\\s+(.*)\\s+(\\{)",
					"captures": {
						"1": { "name": "storage.modifier.cfa" },
						"2": { "patterns":[{ "include": "#extern.head.string"}] },
						"3": { "name": "punctuation.section.block.begin.bracket.curly.extern.cfa" }
					}
				},
				"extern.block": {
					"name": "meta.block.extern.cfa",
					"begin": "(extern\\s+.*\\s+\\{)",
					"end": "(\\})",
					"beginCaptures": {
						"0": { "name": "meta.head.extern.cfa", "patterns":[{ "include": "#extern.head" }] }
					},
					"endCaptures": {
						"0": { "name": "punctuation.section.block.end.bracket.curly.extern.cfa" }
					},
					"contentName": "meta.body.extern.cfa",
					"patterns": [{ "include": "$self" }]
				}
			}
		},
		"declaration": {
			"patterns": [
				{"include": "#declaration.type"},
				{"include": "#declaration.aggregate"}
			],
			"repository": {
				"declaration.type": {
					"patterns": [
							{ "match": "(\\b|^|\\s)(void|bool|char|short|int|long|signed|unsigned|float|double)(\\b|$|\\s)", "name": "storage.type.built-in.primitive.cfa"},
							{ "match": "(\\b|^|\\s)(zero_t|one_t|size_t|ssize_t|intptr_t|uintptr_t|thread\\$|coroutine\\$|generator\\$|monitor\\$)(\\b|$|\\s)", "name": "storage.type.built-in.cfa"},
							{ "match": "(\\b|^|\\s)(extern|static|inline|volatile|const|thread_local)(\\b|$|\\s)", "name": "storage.modifier.cfa"}
					]
				},
				"declaration.aggregate": {
					"patterns": [
						{ "name": "storage.type.struct.cfa"   , "match": "(\\b|^|\\s)struct(\\s+(\\w+))?(\\b|$|\\s)"   , "captures": { "3": { "name": "entity.name.type.struct.cfa"   }} },
						{ "name": "storage.type.union.cfa"    , "match": "(\\b|^|\\s)union(\\s+(\\w+))?(\\b|$|\\s)"    , "captures": { "3": { "name": "entity.name.type.union.cfa"    }} },
						{ "name": "storage.type.enum.cfa"     , "match": "(\\b|^|\\s)enum(\\s+(\\w+))?(\\b|$|\\s)"     , "captures": { "3": { "name": "entity.name.type.enum.cfa"     }} },
						{ "name": "storage.type.trait.cfa"    , "match": "(\\b|^|\\s)trait(\\s+(\\w+))?(\\b|$|\\s)"    , "captures": { "3": { "name": "entity.name.type.trait.cfa"    }} },
						{ "name": "storage.type.generator.cfa", "match": "(\\b|^|\\s)generator(\\s+(\\w+))?(\\b|$|\\s)", "captures": { "3": { "name": "entity.name.type.generator.cfa"}} },
						{ "name": "storage.type.coroutine.cfa", "match": "(\\b|^|\\s)coroutine(\\s+(\\w+))?(\\b|$|\\s)", "captures": { "3": { "name": "entity.name.type.coroutine.cfa"}} },
						{ "name": "storage.type.thread.cfa"   , "match": "(\\b|^|\\s)thread(\\s+(\\w+))?(\\b|$|\\s)"   , "captures": { "3": { "name": "entity.name.type.thread.cfa"   }} },
						{ "name": "storage.type.monitor.cfa"  , "match": "(\\b|^|\\s)monitor(\\s+(\\w+))?(\\b|$|\\s)"  , "captures": { "3": { "name": "entity.name.type.monitor.cfa"  }} },
						{ "name": "storage.type.dtype.cfa"    , "match": "(\\b|^|\\s)dtype(\\s+(\\w+))?(\\b|$|\\s)"    , "captures": { "3": { "name": "entity.name.type.dtype.cfa"    }} },
						{ "name": "storage.type.otype.cfa"    , "match": "(\\b|^|\\s)otype(\\s+(\\w+))?(\\b|$|\\s)"    , "captures": { "3": { "name": "entity.name.type.otype.cfa"    }} },
						{ "name": "storage.type.ttype.cfa"    , "match": "(\\b|^|\\s)ttyp(\\s+(\\w+))?(\\b|$|\\s)"     , "captures": { "3": { "name": "entity.name.type.ttype.cfa"    }} }
					]
				}
			}
		},
		"constant": {
			"patterns": [
				{"include": "#constant.pointer"},
				{"include": "#constant.number"},
				{"include": "#constant.string.single"},
				{"include": "#constant.string.double"},
				{"include": "#constant.endline"}
			],
			"repository": {
				"constant.number": {
					"patterns":[
						{"name": "constant.numeric.binary.cfa", "match": "\\b0[b|B][_01\\.e]+(u?(hh|h|z|l\\d+|L\\d+|ll|l)u?)?"},
						{"name": "constant.numeric.hexadecimal.cfa", "match": "\\b0[x|X][_\\dabcdefABCDEF\\.p]+(u?(hh|h|z|l\\d+|L\\d+|ll|l)u?)?"},
						{"name": "constant.numeric.octal.cfa", "match": "\\b0[_0-7\\.]+(u?(hh|h|z|l\\d+|L\\d+|ll|l)u?)?"},
						{"name": "constant.numeric.decimal.cfa", "match": "\\b[\\d\\.][_\\d\\.e\\+]*(u?(hh|h|z|l\\d+|L\\d+|ll|l)u?)?"}
					]
				},
				"constant.pointer": {
					"patterns":[
						{"name": "constant.language.binary.cfa", "match": "\\b0[b|B][_01]+p"},
						{"name": "constant.language.hexadecimal.cfa", "match": "\\b0[x|X][_\\dabcdefABCDEF]+p"},
						{"name": "constant.language.octal.cfa", "match": "\\b0[_0-7]+p"},
						{"name": "constant.language.decimal.cfa", "match": "\\b[\\d][_\\d\\.e\\+]*p"}
					]
				},
				"constant.string.content": {
					"patterns": [
						{ "name": "constant.character.escape.cfa" , "match": "\\\\."},
						{ "name": "constant.other.placeholder.cfa", "match": "%\\+?(\\.(\\d+|\\*))?(hh|h|ll|l|j|z|t|L)?[diuoxXfFeEgGaAcspn%]"}
					]
				},
				"constant.string.double": {
					"name": "string.quoted.double.cfa",
					"begin": "\"",
					"end": "\"",
					"beginCaptures": {
						"0": { "name": "punctuation.definition.string.begin.cfa" }
					},
					"endCaptures": {
						"0": { "name": "punctuation.definition.string.end.cfa" }
					},
					"patterns": [
						{ "include": "#constant.string.content"}
					]
				},
				"constant.string.single": {
					"name": "string.quoted.single.cfa",
					"begin": "'",
					"end": "'",
					"beginCaptures": { "0": { "name": "punctuation.definition.string.begin.cfa" } },
					"endCaptures"  : { "0": { "name": "punctuation.definition.string.end.cfa"   } },
					"patterns": [
						{ "include": "#constant.string.content"}
					]
				},
				"constant.endline": {
					"name": "constant.character.escape.line-continuation.cfa",
					"match": "\\\\\\s*(//.*)?"
				}
			}
		},
		"operator": {
			"patterns":[
				{
					"name": "keyword.operator.declaration.cfa",
					"match": "\\?\\[\\?\\]|\\^\\?{}|\\?{}|\\?\\(\\)|\\?\\+\\+|\\?--|\\+\\+\\?|--\\?|\\*\\?|\\+\\?|\\-\\?|\\~\\?|\\!\\?|\\?\\\\=\\?|\\?\\\\\\?|\\?\\*=\\?|\\?\\*\\?|\\?/=\\?|\\?/\\?|\\?%=\\?|\\?%\\?|\\?\\+=\\?|\\?\\+\\?|\\?-=\\?|\\?-\\?|\\?<<=\\?|\\?<<\\?|\\?<=\\?|\\?<\\?|\\?>>=\\?|\\?>>\\?|\\?>=\\?|\\?>\\?|\\?==\\?|\\?\\!=\\?|\\?&=\\?|\\?&\\?|\\?\\^=\\?|\\?\\^\\?|\\?\\|=\\?|\\?\\|\\?|\\?=\\?"
				},
				{
					"name": "keyword.operator.cfa",
					"match": "\\?|\\+\\+|--|\\~|\\!|\\=|\\\\|->|\\*=|\\*|/=|/|%=|%|\\+=|\\+|-=|-|<<=|<<|<=|<|>>=|>>|>=|>|==|\\!=|&&|&=|&|\\^=|\\^|\\|\\||\\|=|\\||="
				}
			]
		},
		"statement": {
			"patterns":[
				{ "match": "\\b(if)\\s*\\("         , "captures": { "1": { "name": "keyword.control.if.cfa"        } } },
				{ "match": "\\b(for)\\s*\\("        , "captures": { "1": { "name": "keyword.control.for.cfa"       } } },
				{ "match": "\\b(while)\\s*\\("      , "captures": { "1": { "name": "keyword.control.while.cfa"     } } },
				{ "match": "\\b(switch)\\s*\\("     , "captures": { "1": { "name": "keyword.control.switch.cfa"    } } },
				{ "match": "\\b(choose)\\s*\\("     , "captures": { "1": { "name": "keyword.control.choose.cfa"    } } },
				{ "match": "\\b(waitfor)\\s*\\("    , "captures": { "1": { "name": "keyword.control.waitfor.cfa"   } } },
				{ "match": "\\b(when)\\s*\\("       , "captures": { "1": { "name": "keyword.control.when.cfa"      } } },
				{ "match": "\\b(timeout)\\s*\\("    , "captures": { "1": { "name": "keyword.control.timeout.cfa"   } } },
				{ "match": "\\b(or)\\b"             , "captures": { "1": { "name": "keyword.contol.or.cfa"         } } },
				{ "match": "\\b(else)\\b"           , "captures": { "1": { "name": "keyword.contol.else.cfa"       } } },
				{ "match": "\\b(do)\\b"             , "captures": { "1": { "name": "keyword.contol.do.cfa"         } } },
				{ "match": "\\b(case)\\b"           , "captures": { "1": { "name": "keyword.contol.case.cfa"       } } },
				{ "match": "\\b(default)\\b"        , "captures": { "1": { "name": "keyword.contol.default.cfa"    } } },
				{ "match": "\\b(suspend)\\b"        , "captures": { "1": { "name": "keyword.contol.suspend.cfa"    } } },
				{ "match": "\\b(try)\\b"            , "captures": { "1": { "name": "keyword.contol.try.cfa"        } } },
				{ "match": "\\b(catch(Resume)?)\\b" , "captures": { "1": { "name": "keyword.contol.catch.cfa"      } } },
				{ "match": "\\b(finally)\\b"        , "captures": { "1": { "name": "keyword.contol.finally.cfa"    } } },
				{ "match": "\\b(goto)\\b"           , "captures": { "1": { "name": "keyword.contol.goto.cfa"       } } },
				{ "match": "\\b(return)\\b"         , "captures": { "1": { "name": "keyword.contol.return.cfa"     } } },
				{ "match": "\\b(break)\\b"          , "captures": { "1": { "name": "keyword.contol.break.cfa"      } } },
				{ "match": "\\b(continue)\\b"       , "captures": { "1": { "name": "keyword.contol.continue.cfa"   } } },
				{ "match": "\\b(fallthr(u|ough))\\b", "captures": { "1": { "name": "keyword.contol.fallthrough.cfa"} } },
				{ "match": "\\b(throw(Resume)?)\\b" , "captures": { "1": { "name": "keyword.contol.throw.cfa"      } } }
			]
		}
	}
}