File tree 2 files changed +10
-30
lines changed 2 files changed +10
-30
lines changed Original file line number Diff line number Diff line change @@ -145,10 +145,16 @@ trait SyntaxAnalyser extends PositionedParserUtilities {
145
145
name ^^ Var
146
146
147
147
lazy val name =
148
- " [a-zA-Z]+" .r ~ regexnows (" [0-9]*" .r) ^^ {
149
- case base ~ index =>
150
- Name (base, if (index.isEmpty) None else Some (index.toInt))
151
- }
148
+ " [a-zA-Z]+[0-9]+" .r ^^ (
149
+ fullname => {
150
+ val (base, index) = fullname.span (_.isLetter)
151
+ Name (base, Some (index.toInt))
152
+ }
153
+ ) |
154
+ " [a-zA-Z]+" .r ^^ (
155
+ base =>
156
+ Name (base, None )
157
+ )
152
158
153
159
}
154
160
Original file line number Diff line number Diff line change @@ -119,32 +119,6 @@ trait ParserUtilities extends RegexParsers with PackratParsers {
119
119
}
120
120
}
121
121
122
- /**
123
- * Create a parser that matches a regex string, but doesn't skip whitespace
124
- * first. This operation is useful if you want to recognise parts of a lexical
125
- * symbol with different regular expressions so you can use the parts
126
- * separately. Otherwise you have to parse with one regex and then split the
127
- * resulting string to get at its parts. Based on `RegexParser.regex` in the
128
- * Scala library.
129
- */
130
- def regexnows (r : Regex ) : Parser [String ] =
131
- Parser { in =>
132
- val source = in.source
133
- val start = in.offset
134
- (r findPrefixMatchOf (source.subSequence (start, source.length))) match {
135
- case Some (matched) =>
136
- Success (source.subSequence (start, start + matched.end).toString,
137
- in.drop (matched.end))
138
- case None =>
139
- val found =
140
- if (start == source.length ())
141
- " end of source"
142
- else
143
- s " ` ${source.charAt (start)}' "
144
- Failure (s " string matching regex ` $r' expected but $found found " , in)
145
- }
146
- }
147
-
148
122
/**
149
123
* Convenience conversion to lift parsers that return 2-tilde-tuples to parsers
150
124
* that return regular 2-tuples.
You can’t perform that action at this time.
0 commit comments