@@ -49,8 +49,8 @@ internal postfix func |? <T>(parser: Parser<T>.Function) -> Parser<T?>.Function
49
49
}
50
50
51
51
private let char_control = NSCharacterSet . controlCharacterSet ( )
52
- private let char_text = char_control. invertedSet - NSCharacterSet. whitespaceAndNewlineCharacterSet ( )
53
- private let char_word = char_text - " ,() "
52
+ private let char_text = char_control. invertedSet - NSCharacterSet. newlineCharacterSet ( )
53
+ private let char_word = char_text - " ,() " - NSCharacterSet . whitespaceCharacterSet ( )
54
54
private let char_space = NSCharacterSet . whitespaceCharacterSet ( )
55
55
private let char_break = NSCharacterSet . newlineCharacterSet ( )
56
56
@@ -60,11 +60,15 @@ private let char_end = char_control - NSCharacterSet.whitespaceAndNewlineCharact
60
60
private let wordStart : Parser < String > . Function = % ( char_word - " #' \" " )
61
61
private let wordChars : Parser < String > . Function = ( % ( char_word - " ' \" " ) ) * --> { strings in join ( " " , strings) }
62
62
private let word : Parser < String > . Function = wordStart ++ wordChars --> ( + )
63
- private let string : Parser < String > . Function = ( % char_text | % char_space) + --> { strings in join ( " " , strings) }
64
63
private let br : Parser < ( ) > . Function = ignore ( % char_break )
65
64
private let eof : Parser < ( ) > . Function = { $0 == " " ? ( ( ) , " " ) : nil }
66
- private let comment : Parser < ( ) > . Function = ignore ( % " # " ++ string ++ ( br | eof) )
67
- private let quoted : Parser < String > . Function = ( ignore ( % " ' " ) ++ string ++ ignore( % " ' " ) ) | ( ignore ( % " \" " ) ++ string ++ ignore( % " \" " ) )
65
+ private let comment : Parser < ( ) > . Function = ignore ( % " # " ++ ( % char_text) + ++ ( br | eof) )
66
+ // TODO: Escape sequences.
67
+ private let singleQuotedChars : Parser < String > . Function = ( % ( char_text - " ' " ) ) * --> { strings in join ( " " , strings) }
68
+ private let singleQuoted : Parser < String > . Function = ignore ( % " ' " ) ++ singleQuotedChars ++ ignore( % " ' " )
69
+ private let doubleQuotedChars : Parser < String > . Function = ( % ( char_text - " \" " ) ) * --> { strings in join ( " " , strings) }
70
+ private let doubleQuoted : Parser < String > . Function = ignore ( % " \" " ) ++ doubleQuotedChars ++ ignore( % " \" " )
71
+ private let quoted : Parser < String > . Function = singleQuoted | doubleQuoted
68
72
private let requiredSpace : Parser < ( ) > . Function = ignore ( ( comment | % char_space) + )
69
73
private let optionalSpace : Parser < ( ) > . Function = ignore ( ( comment | % char_space) * )
70
74
private let separator : Parser < ( ) > . Function = ignore ( optionalSpace ++ % " , " ++ optionalSpace)
@@ -125,7 +129,7 @@ private let block: Int -> Parser<()>.Function = { n in const(nil) }
125
129
/// Parses a single descendent element.
126
130
///
127
131
/// This is an element which may be an in-line descendent, and which may further have in-line descendents of its own.
128
- private let descendent = ( word | quoted ) --> { Node ( value: $0) }
132
+ private let descendent = value --> { Node ( value: $0) }
129
133
130
134
/// Parses a sequence of hierarchically descending elements, e.g.:
131
135
///
0 commit comments