1use oak_core::language::{Language, LanguageCategory};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub struct JsonLanguage {
6 pub trailing_comma: bool,
8 pub bare_keys: bool,
10 pub single_quotes: bool,
12 pub comments: bool,
14 pub hex_numbers: bool,
16 pub infinity_and_nan: bool,
18}
19
20impl JsonLanguage {
21 pub fn standard() -> Self {
23 Self::default()
24 }
25
26 pub fn json5() -> Self {
28 Self { trailing_comma: true, bare_keys: true, single_quotes: true, comments: true, hex_numbers: true, infinity_and_nan: true }
29 }
30
31 pub fn relaxed() -> Self {
33 Self { trailing_comma: true, bare_keys: true, single_quotes: true, comments: true, hex_numbers: true, infinity_and_nan: true }
34 }
35}
36
37impl Default for JsonLanguage {
38 fn default() -> Self {
39 Self { trailing_comma: false, bare_keys: false, single_quotes: false, comments: false, hex_numbers: false, infinity_and_nan: false }
40 }
41}
42
43impl Language for JsonLanguage {
44 const NAME: &'static str = "json";
45 const CATEGORY: LanguageCategory = LanguageCategory::Config;
46
47 type TokenType = crate::kind::JsonSyntaxKind;
48 type ElementType = crate::kind::JsonSyntaxKind;
49 type TypedRoot = crate::ast::JsonRoot;
50}