%YAML 1.2
---
name: KDL
file_extensions: [kdl]
scope: source.kdl
contexts:
  main:
    - include: comments
    - include: strings
    - include: nodes
    - include: numbers
  comments:
    - match: '//'
      push: [{meta_scope: comment.line.double-slash.kdl}, {match: '$', pop: true}]
    - match: '/\*'
      push: [{meta_scope: comment.block.kdl}, {match: '\*/', pop: true}]
    - match: '/-'
      scope: comment.slashdash.kdl
  strings:
    - match: '"'
      push:
        - meta_scope: string.quoted.double.kdl
        - match: '\\.'
          scope: constant.character.escape.kdl
        - match: '"'
          pop: true
    - match: 'r#*"'
      push:
        - meta_scope: string.quoted.raw.kdl
        - match: '"#*'
          pop: true
  nodes:
    - match: '\b[\w][\w\-]*\b(?=\s|{|\()'
      scope: entity.name.tag.kdl
    - match: '[\w][\w\-]*(?==)'
      scope: variable.other.property.kdl
    - match: '\b(true|false|null)\b'
      scope: constant.language.kdl
    - match: '\(\w+\)'
      scope: entity.name.type.kdl
  numbers:
    - match: '\b0[xX][0-9a-fA-F_]+\b'
      scope: constant.numeric.hex.kdl
    - match: '\b0[bB][01_]+\b'
      scope: constant.numeric.binary.kdl
    - match: '\b0[oO][0-7_]+\b'
      scope: constant.numeric.octal.kdl
    - match: '[+-]?\b\d[\d_]*(\.\d[\d_]*)?(e[+-]?\d+)?\b'
      scope: constant.numeric.kdl
