summaryrefslogtreecommitdiffstats
path: root/assets/syntaxes/02_Extra/Fstab.sublime-syntax
blob: 0753e5f5761b097ec7de435cbfe28c60d6bb9241 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: fstab
file_extensions:
  - fstab
  - crypttab
scope: source.fstab

contexts:
  main:
    - include: comment
    - match: '^'
      push: fstab_device
      comment: leading spaces

  fstab_device:
    - include: comment
    - match: '\s*([^=\s]+=)([^\s]+)\s*'
      comment: device by uuid or label
      set: fstab_mountpoint
      captures:
        1: punctuation.accessor
        2: keyword.other.device
    - match: '\s*(//|\\\\)([^\s]+)\s*'
      comment: device by samba share
      set: fstab_mountpoint
      captures:
        1: punctuation.accessor
        2: keyword.other.device
    - match: '\s*([^\s]+)(:)([^\s]+)\s*'
      comment: device by server
      set: fstab_mountpoint
      captures:
        1: keyword.other.device
        2: punctuation.accessor
        3: keyword.other.device
    - match: '\s*[^\s/\\]+\s*'
      comment: device by dev name
      set: fstab_mountpoint
      scope: keyword.other.device
    - match: '\s*(/dev/)([^\s]+)\s*'
      comment: device by dev path
      set: fstab_mountpoint
      captures: 
        1: punctuation.accessor
        2: keyword.other.device
    - match: '\s*([^\s/]*/)*([^\s]+)\s*'
      comment: device by unknown path
      set: fstab_mountpoint
      captures:
        1: punctuation.accessor
        2: keyword.other.device
    - include: clear

  fstab_mountpoint:
    - include: comment
    - match: '\s*/[^\s]*\s*'
      comment: mount point
      set: fstab_filesystem
      scope: string.unquoted.mountpoint
    - match: '\s*[^\s]+\s*'
      comment: mount point without leading slash (invalid)
      set: fstab_filesystem
      scope: invalid.illegal
    - include: clear

  fstab_filesystem:
    - include: comment
    - match: '\s*[^\s]+\s*'
      comment: filesystem type
      set: fstab_options
      scope: variable.parameter.filesystem
    - include: clear

  fstab_options:
    - include: comment
    - match: '([^\s,=]+)(=)([^\s,]+)'
      comment: key-value option
      captures:
       1: entity.name.option
       2: entity.other.separator
       3: variable.parameter
    - match: '[^\s,]+'
      comment: flag option
      scope: entity.name.option
    - match: ','
      comment: option separator
      scope: punctuation.separator
    - match: '\s+'
      comment: next field
      set: fstab_dump
    - include: clear

  fstab_dump:
    - include: comment
    - match: '\s*[01]\s*'
      comment: dump field
      scope: constant.numeric
      set: fstab_pass
    - match: '\s*[^\s]+\s*'
      comment: invalid dump field
      scope: invalid.illegal
      set: fstab_pass
    - include: clear

  fstab_pass:
    - include: comment
    - match: '\s*[01]\s*'
      comment: pass field
      scope: constant.numeric
      set: expected_eol
    - match: '\s*[^\s]+\s*'
      comment: invalid pass field
      scope: invalid.illegal
      set: expected_eol
    - include: clear

  expected_eol:
    - include: comment
    - include: clear
    - match: '.*'
      scope: invalid.illegal

  comment:
    - match: '\s*#.*$'
      comment: comment using the number sign
      scope: comment.line

  clear:
    - match: '.*$'
      comment: used for clearing the context
      pop: true