Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert .sublime-syntax (YAML) to VSCode-compatible syntax

I have created a .sublime-syntax syntax definition for Sublime Text 3, for my own programming language (Arturo).

Here is the whole syntax from the corresponding repository:

%YAML 1.2
---
file_extensions:
  - art
scope: source.arturo
contexts:
    ########################
    # MAIN
    ########################

    main:
        ## COMMENTS

        # She-bang line
        - match: '#!'
          scope: punctuation.definition.comment.arturo
          push: line_comment

        # Single-line comments
        - match: ;
          scope: punctuation.definition.comment.arturo
          push: line_comment

        ### STRINGS

        # Double-quoted string literals
        - match: '"'
          scope: string.quoted.double.arturo
          push: double_quoted_string

        # FullLine strings
        - match: «
          scope: keyword.operator.arturo
          push: fullline_string

        # Curly strings
        - match: '{'
          scope: text.plain.arturo
          push: curly_string

        # Triple-dash strings
        - match: '---'
          scope: string.quoted.double.arturo
          push: triple_dash_string

        ### LITERALS

        # numbers
        - match: '[0-9]+(\.[0-9]+)?'
          scope: text.plain.arturo

        # characters
        - match: '`.`'
          scope: string.quoted.double.arturo

        # boolean
        - match: 'true|false'
          scope: constant.language.arturo

        # boolean
        - match: 'null'
          scope: constant.language.arturo

        ### SYMBOLS

        # syntactic sugar
        - match: '(->|=>|\|)'
          scope: markup.heading.arturo punctuation.definition.heading.arturo

        # operators
        - match: '@|#|\+|\||\*|\$|\-|\%|\/|\.\.|\^|~|=|<|>|\\|\-\-\-'
          scope: keyword.operator.arturo

        ### LABELS

        # label
        - match: '([\w]+\b\??:)'
          scope: entity.name.arturo

    ########################
    # SUBSCOPES
    ########################

    line_comment:
      - meta_scope: comment.line.arturo
      - match: $
        pop: true

    double_quoted_string:
      - meta_include_prototype: false
      - meta_scope: string.quoted.double.arturo
      - match: '\\.'
        scope: constant.character.escape.arturo
      - match: '\|'
        scope: markup.heading.arturo punctuation.definition.heading.arturo
        push:
        - clear_scopes: true
        - meta_scope: source.arturo
        - match: '\|'
          scope: markup.heading.arturo punctuation.definition.heading.arturo
          pop: true
        - include: 'main'
      - match: '"'
        scope: string.quoted.double.arturo
        pop: true
      - include: escaped

    fullline_string:
      - meta_scope: markup.heading.arturo
      - match: $
        pop: true

    curly_string:
      - meta_include_prototype: false
      - meta_scope: text.plain.arturo
      - match: '\\.'
        scope: constant.character.escape.arturo
      - match: '\|'
        scope: markup.heading.arturo punctuation.definition.heading.arturo
        push:
        - clear_scopes: true
        - meta_scope: source.arturo
        - match: '\|'
          scope: markup.heading.arturo punctuation.definition.heading.arturo
          pop: true
        - include: 'main'

      - match: '!html'
        scope: markup.heading.arturo punctuation.definition.heading.arturo
        push: Packages/HTML/HTML.sublime-syntax
        with_prototype:
        - match: '\|'
          scope: markup.heading.arturo punctuation.definition.heading.arturo
          push:
          - clear_scopes: true
          - meta_scope: source.arturo
          - match: '\|'
            scope: markup.heading.arturo punctuation.definition.heading.arturo
            pop: true
          - include: 'main'
        - match: 'html!'
          scope: markup.heading.arturo punctuation.definition.heading.arturo
          pop: true

      - match: '!latex'
        scope: markup.heading.arturo punctuation.definition.heading.arturo
        push: Packages/LaTeX/TeX.sublime-syntax
        with_prototype:
        - match: '\|'
          scope: markup.heading.arturo punctuation.definition.heading.arturo
          push:
          - clear_scopes: true
          - meta_scope: source.arturo
          - match: '\|'
            scope: markup.heading.arturo punctuation.definition.heading.arturo
            pop: true
          - include: 'main'
        - match: 'latex!'
          scope: markup.heading.arturo punctuation.definition.heading.arturo
          pop: true

      - match: '}'
        scope: text.plain.arturo
        pop: true
      - include: escaped

    triple_dash_string:
      - meta_include_prototype: false
      - meta_scope: string.quoted.double.arturo
      - match: '\\.'
        scope: constant.character.escape.arturo
      - match: '\|'
        scope: markup.heading.arturo punctuation.definition.heading.arturo
        push:
        - clear_scopes: true
        - meta_scope: source.arturo
        - match: '\|'
          scope: markup.heading.arturo punctuation.definition.heading.arturo
          pop: true
        - include: 'main'
      - match: '---'
        scope: string.quoted.double.arturo
        pop: true
      - include: escaped

I'm now trying to convert it to VSCode (and Atom-) compatible syntax definition but despite having gone through good part of the documentation, I'm still confused.

  • First of all, can it be done? (without sacrificing functionality)
  • How? (Is there any automated tool for that? Are the changes documented anywhere?)
like image 310
Dr.Kameleon Avatar asked Jul 21 '26 23:07

Dr.Kameleon


1 Answers

Check the documentation here

They suggest this tool to convert YAML to JSON

like image 135
Johntor Avatar answered Jul 23 '26 18:07

Johntor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!