<commit_before>scopeName : 'source.g-code.cncpilot';
name: 'G-Code - CNCpilot'
fileTypes: [
  'ncs', # CNCpilot or ManualPlus
]

foldingStartMarker: 'UNIT'
foldingStopMarker: 'END_OF_UNIT'
limitLineLength: false

patterns: [
    {
      comment: 'line number'
      match: '^N\\s*\\d+'
      name: 'comment.line.g-code'
    },
    {
      comment: 'comment until the end of the line'
      match: ';(.*)$'
      name: 'comment.line.g-code'
    },
    {
      comment: 'comment'
      match: '(\\(.*\\))$'
      name: 'comment.line.g-code'
    },
    {
        comment: 'commented out line'
        match: '^(/N\\d+)\\s+(.*)$'
        name: 'comment.block.g-code'
    },
    {
        comment: 'program meta info'
        match: '^#(.*)$'
        name: 'comment.block.g-code'
    },
    {
        comment: 'line termination'
        match: '\\*$'
        name: 'comment.line.g-code'
    },
    {
        comment: 'program name'
        match: '(%)([\\w\\d_]+(?:(?:\\.nc)|(?:\\.NCS))?)(\\s+\\".*\\")?'
        captures:
            1:
                name: 'keyword.control.g-code'
            2:
                name: 'variable.string.g-code'
            3:
                name: 'constant.string.g-code'
    },
    {
        comment: 'tool call'
        match: '\\b(T)(?:(=)(\\".*\\"))|(\\d+(?:\\.\\d+)?)\\b'
        captures:
            1:
                name: 'keyword.control.g-code'
            2:
                name: 'keyword.control.g-code'
            3:
                name: 'constant.string.g-code'
            4:
                name: 'constant.numeric.g-code'
    },
    {
      comment: 'Ingeger Values: g-command'
      match: '\\b(G)(\\d+)\\b'
      captures:
        1:
          name: 'keyword.control.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'Ingeger Values: machin function, spindle speed, radius, l, p'
      match: '\\b([GMSRLPQHVDWC])(\\d+)\\b'
      captures:
        1:
          name: 'keyword.operator.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'Float Values: feed rate'
      match: '\\b([FB])(\\d+(?:\\.\\d+)?)\\b'
      captures:
        1:
          name: 'keyword.operator.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'Signed Float Values:'
      match: '\\b([P])([\\+-]?\\d+(?:\\.\\d+)?)\\b'
      captures:
        1:
          name: 'keyword.operator.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'cartesian coordinate'
      match: '\\b([XYZ])([\\+-]?\\d+(?:\\.\\d+)?)\\b'
      captures:
        1:
          name: 'keyword.operator.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'circle center offset'
      match: '\\b([IJK])([\\+-]?\\d+(?:\\.\\d+)?)\\b'
      captures:
        1:
          name: 'keyword.operator.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'Keywords: groups'
      match: '\\b((?:UNIT)|(?:END_OF_UNIT))\\b'
      captures:
        1:
          name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: CNCpilot od ManualPlus German'
      match: '\\b((?:PROGRAMMKOPF)|(?:REVOLVER)|(?:ROHTEIL)|(?:FERTIGTEIL)|(?:BEARBEITUNG))\\b'
      captures:
        1:
          name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: GLOBAL'
      match: '\\b((?:ENDE)|(?:RETURN))\\b'
      captures:
        1:
          name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: Flow control - Part1'
      match: '\\b((?:IF)|(?:THEN)|(?:ELSE)|(?:ENDIF)|(?:WHILE)|(?:ENDWHILE)|(?:FOR)|(?:TO)|(?:bENDFOR))\\b'
      captures:
        1:
          name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: Flow control - Part2'
      match: '\\b((?:SWITCH)|(?:CASE)|(?:ENDSWITCH)|(?:BREAK)|(?:DEFAULT))\\b'
      captures:
        1:
          name: 'keyword.control.g-code'
    },
]<commit_msg>reorganised g-code grammar for cnc pilot<commit_after>scopeName : 'source.g-code.cncpilot';
name: 'G-Code - CNCpilot';
fileTypes: [
  'ncs',
  'nc',
]

foldingStartMarker: 'UNIT';
foldingStopMarker: 'END_OF_UNIT';
firstLineMatch: '"TURN_V1\\.0"$';
limitLineLength: true;

patterns: [
    {
      comment: 'line number'
      match: '^N\\s*\\d+'
      name: 'comment.line.g-code'
    },
    {
      comment: 'unit block'
      name: 'keyword.control.g-code'
      contentName: 'keyword.operator.g-code';
      begin: '\\[<unit'
      end: '/>\\]'
    },
    {
      comment: 'comment block in square brackets'
      match: '\\[.*?\\]'
      name: 'comment.block.g-code'
    },
    {
      comment: 'string in double quouts'
      match: '"[\\w\\s#]*"'
      name: 'variable.string.g-code'
    },
    {
        comment: 'program meta info'
        match: '^#(.*)$'
        name: 'comment.block.g-code'
    },
    {
        comment: 'program name'
        match: '(%)([\\w\\d_]+\\.[ncsNCS]+)(\\s+".*")?'
        captures:
            1:
                name: 'keyword.control.g-code'
            2:
                name: 'variable.string.g-code'
            3:
                name: 'constant.string.g-code'
    },
    {
      comment: 'G-Command'
      match: '\\b(G)(\\d+)\\b'
      captures:
        1:
          name: 'keyword.control.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'Machine Function'
      match: '\\b(M)(\\d+)\\b'
      captures:
        1:
          name: 'keyword.control.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'Tool call'
      match: '\\b(T)(\\d+)\\b'
      captures:
        1:
          name: 'keyword.control.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'axis values'
      match: '\\b([XYZ])([\\+-]?\\d+(?:\\.\\d+)?)\\b'
      captures:
        1:
          name: 'keyword.operator.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'Spindle speed'
      match: '\\b(S)(\\d+)\\b'
      captures:
        1:
          name: 'keyword.operator.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'feed rate'
      match: '\\b(F)(\\d+(?:\\.\\d+)?)\\b'
      captures:
        1:
          name: 'keyword.operator.g-code'
        2:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'Keyword: Unit start'
      match: '\\b(UNIT ID)'
      name: 'keyword.control.g-code'
    },
    {
      comment: 'Keyword: Unit end'
      match: '\\b(END_OF_UNIT) (S)(\\d+)'
      captures:
        1:
          name: 'keyword.control.g-code'
        2:
          name: 'keyword.operator.g-code'
        3:
          name: 'constant.numeric.g-code'
    },
    {
      comment: 'Keywords: Groups German'
      match: '\\b((?:PROGRAMMKOPF)|(?:REVOLVER)|(?:ROHTEIL)|(?:FERTIGTEIL)|(?:BEARBEITUNG))\\b'
      name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: Groups English'
      match: '\\b((?:CONST)|(?:VAR)|(?:MACHINING))\\b'
      name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: GLOBAL'
      match: '\\b((?:ENDE)|(?:RETURN))\\b'
      name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: Flow control - Part1'
      match: '\\b((?:IF)|(?:OR)|(?:AND)|(?:THEN)|(?:ELSE)|(?:ENDIF))\\b'
      name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: Flow control - Loop'
      match: '\\b((?:WHILE)|(?:ENDWHILE)|(?:FOR)|(?:TO)|(?:bENDFOR))\\b'
      name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: Flow control - Switch'
      match: '\\b((?:SWITCH)|(?:CASE)|(?:ENDSWITCH)|(?:BREAK)|(?:DEFAULT))\\b'
      name: 'keyword.control.g-code'
    },
    {
      comment: 'Keywords: Functions'
      match: '\\b((?:INPUT)|(?:PRINT)|(?:PARA)|(?:DEF)|(?:NDEF)|(?:INT))\\b'
      name: 'keyword.control.g-code'
    },
]
{'fraction_non_alphanumeric': 0.21554233641311227, 'fraction_numerical': 0.005948614099481078, 'mean_word_length': 1.6490110626885686, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7117361', 'n_tokens_mistral': 2914, 'n_tokens_neox': 2869, 'n_words': 463}