Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tidy up lexer; merge ScalaLexer and Lexer, pull out ModeStack trait, …
…misc
- Loading branch information
Showing
11 changed files
with
333 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,5 +64,5 @@ object Keywords { | |
"|" -> PIPE, | ||
"~" -> TILDE, | ||
"!" -> EXCLAMATION) | ||
|
||
} | ||
} |
100 changes: 0 additions & 100 deletions
100
scalariform/src/main/scala/scalariform/lexer/Lexer.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,5 +32,4 @@ class XmlMode extends LexerMode { | |
|
||
def nestingLevel = tagNestLevel | ||
|
||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
scalariform/src/main/scala/scalariform/lexer/ModeStack.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package scalariform.lexer | ||
|
||
import scala.collection.mutable.Stack | ||
|
||
/** | ||
* Keeping track of nesting level of XML within Scala. | ||
*/ | ||
trait ModeStack { self: ScalaLexer ⇒ | ||
|
||
private val modeStack = new Stack[LexerMode] | ||
|
||
modeStack.push(new ScalaMode) | ||
|
||
protected def popMode() { modeStack.pop() } | ||
|
||
protected def isRootMode = modeStack.size == 1 | ||
|
||
protected def switchToScalaModeAndFetchToken() { | ||
modeStack.push(new ScalaMode) | ||
fetchScalaToken() | ||
} | ||
|
||
protected def switchToXmlModeAndFetchToken() { | ||
modeStack.push(new XmlMode) | ||
fetchXmlToken() | ||
} | ||
|
||
protected def xmlMode: XmlMode = modeStack.head.asInstanceOf[XmlMode] | ||
|
||
protected def isXmlMode = modeStack.head.isInstanceOf[XmlMode] | ||
|
||
protected def scalaMode: ScalaMode = modeStack.head.asInstanceOf[ScalaMode] | ||
|
||
} |
Oops, something went wrong.