/scalate-jsp-converter/src/main/scala/org/fusesource/scalate/converter/MarkupScanner.scala
http://github.com/scalate/scalate · Scala · 60 lines · 18 code · 15 blank · 27 comment · 0 complexity · c918b5f556452299cf4f74bbae4e79f4 MD5 · raw file
- /**
- * Copyright (C) 2009-2011 the original author or authors.
- * See the notice.md file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.fusesource.scalate.converter
- import org.fusesource.scalate.support.ScalaParseSupport
- class MarkupScanner extends ScalaParseSupport {
- override def skipWhitespace = false
- // ident {nmstart}{nmchar}*
- def IDENT = (nmstart ~ rep(nmchar)) ^^ { case n ~ l => n + l.mkString("") }
- // nmstart [_a-z]|{nonascii}|{escape}
- private def nmstart = """[_a-zA-Z]""".r | nonascii | escape
- // nonascii [^\0-\177]
- private def nonascii = """[^\x00-\xB1]""".r
- // unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
- private def unicode = """\\[0-9a-fA-F]{1,6}(\r\n|[ \n\r\t\f])?""".r
- // escape {unicode}|\\[^\n\r\f0-9a-f]
- private def escape = unicode | """\\[^\n\r\f0-9a-fA-F]""".r
- // nmchar [_a-z0-9-]|{nonascii}|{escape}
- private def nmchar = """[_a-zA-Z0-9-]""".r | nonascii | escape
- // string {string1}|{string2}
- def STRING = string1 | string2
- // string1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*\"
- private[this] val string1 = ("\"" ~> rep("""[^\n\r\f\\"]""".r | ("\\" + nl).r | nonascii | escape) <~ "\"") ^^ { case l => l.mkString("") }
- // string2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*\'
- private[this] val string2 = ("'" ~> rep("""[^\n\r\f\']""".r | ("\\" + nl).r | nonascii | escape) <~ "'") ^^ { case l => l.mkString("") }
- // nl \n|\r\n|\r|\f
- private[this] val nl = """\n|\r\n|\r|\f"""
- val S = """\s+""".r
- val repS = """[\s]*""".r
- val rep1S = """[\s]+""".r
- }