@@ -9,28 +9,29 @@ import scala.build.preprocessing.directives.Directive
9
9
object TemporaryDirectivesParser {
10
10
11
11
private def ws [_ : P ] = P (" " .rep(1 ))
12
+ private def optWs [_ : P ] = P (" " .rep(0 ))
12
13
private def nl [_ : P ] = P ((" \r " .? ~ " \n " ).rep(1 ))
13
14
private def emptyLine [_ : P ] = P (ws.rep() ~ nl)
14
15
15
16
private def singleLineComment [_ : P ] =
16
- P (ws.rep() ~ ! (" //" ~ ws ~ " require" ) ~ ! (" //" ~ ws ~ " using" ) ~ " //" ~ P (CharPred (c =>
17
+ P (ws.rep() ~ ! (" //" ~ optWs ~ " require" ) ~ ! (" //" ~ optWs ~ " using" ) ~ " //" ~ P (CharPred (c =>
17
18
c != '\n '
18
19
)).rep() ~ nl)
19
20
.map(_ => ())
20
21
21
22
private def directive [_ : P ] = {
22
23
def sc = P (" ;" )
23
24
def tpe = {
24
- def commentedUsingTpe = P (" //" ~ ws ~ Index ~ " using" )
25
+ def commentedUsingTpe = P (" //" ~ optWs ~ Index ~ " using" )
25
26
.map(actualStartIdx => (Directive .Using : Directive .Type , Some (actualStartIdx)))
26
27
def usingKeywordTpe = P (" using" )
27
28
.map(_ => (Directive .Using : Directive .Type , None ))
28
29
def usingTpe = P (ws.? ~ (commentedUsingTpe | usingKeywordTpe) ~ ! (ws ~ " target" ))
29
- def commentedRequireTpe = P (" //" ~ ws ~ Index ~ " require" )
30
+ def commentedRequireTpe = P (" //" ~ optWs ~ Index ~ " require" )
30
31
.map(actualStartIdx => (Directive .Require : Directive .Type , Some (actualStartIdx)))
31
32
def requireKeywordTpe = P (" require" )
32
33
.map(_ => (Directive .Require : Directive .Type , None ))
33
- def commentedUsingTargetTpe = P (" //" ~ ws ~ Index ~ " using" ~ ws ~ " target" )
34
+ def commentedUsingTargetTpe = P (" //" ~ optWs ~ Index ~ " using" ~ ws ~ " target" )
34
35
.map(actualStartIdx => (Directive .Require : Directive .Type , Some (actualStartIdx)))
35
36
def usingTargetKeywordTpe = P (" using" ~ ws ~ " target" )
36
37
.map(_ => (Directive .Require : Directive .Type , None ))
0 commit comments