summaryrefslogtreecommitdiff
path: root/src/piraha/pegs/configuration.peg
blob: ade602bcdb27f79c2e53801207379b21cc80bbde (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
# The skipper is a crucial sub-pattern
# that is activated by any whitespace in the
# grammar file
skipper = \b([\ \t\n\r\b]|\#[^\n]*|\\[\r\n])*

any = [^]
keywords = \b(?i:script|lang|provides|requires|optional)\b
name = (?!{-keywords})(?i:[a-z_][a-z0-9_\.]*\b)
num = [+\-]?[0-9]+
script = (?i: script( {name}|))
lang = (?i: lang( {name}|))

option = {name}

provides = (?i:
    provides {name} \{
        ({script}?
         {lang}
         ( options {option}( {option})* |)|)
    \}
  )

requires = (?i:
    requires (thorns:|) {name}([ \t]*{name})*
  )

ifactive = (?i:_ifactive)
optional = (?i:
    optional{ifactive}? {name}([ \t]+{name})* \{ ( {name} )* \}
  )

config = ({provides} |{requires} |{optional} )* $