Skip to content

Commit

Permalink
Swapped out Scala parser combinators library for FastParse
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisAng committed Mar 10, 2016
1 parent 51fb52a commit 2c4baa9
Show file tree
Hide file tree
Showing 10 changed files with 602 additions and 403 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ sealed case class RedoResponse(src: String) extends Response
sealed trait Action extends Event
sealed case class CreateNode(node: Nodal, src: String) extends Action
sealed case class UpdateNode(node: Nodal, updatedNode: Nodal, src: String) extends Action
sealed case class MoveNode(node: Nodal, x:Double, y:Double, src: String) extends Action
sealed case class DestroyNode(node: Nodal, src: String) extends Action

sealed case class CreateFact(fact: Fact, src: String) extends Action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ object EventBus {
val CreateStoryEvents = eventBus collect { case e: CreateStory => e }
val UpdateStoryPropertiesEvents = eventBus collect { case e: UpdateStoryProperties => e }

val MoveNodeEvents = eventBus collect { case e: MoveNode => e }

/**
* Event stream of all `Completion`s
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ trait NarrativeViewer {
* The plugin is automatically hooked into the appropriate event streams
*/
EventBus.NodeCreatedEvents foreach { n => onNodeCreated(n.node) }
EventBus.MoveNodeEvents foreach { n => onMoveNode(n.node, n.x, n.y) }
EventBus.NodeUpdatedEvents foreach { n => onNodeUpdated(n.node, n.updatedNode) }
EventBus.NodeDestroyedEvents foreach { n => onNodeDestroyed(n.node) }

Expand All @@ -31,22 +30,13 @@ trait NarrativeViewer {
def onNodeCreated(node: Nodal): Unit

/**
* Defines what to do when a node is updated
*
* @param node The node to be updated
* @param updatedNode The same node with the updates already applied
*/
* Defines what to do when a node is updated
*
* @param node The node to be updated
* @param updatedNode The same node with the updates already applied
*/
def onNodeUpdated(node: Nodal, updatedNode: Nodal): Unit

/**
* Defines what to do when a node should move
*
* @param node The node to be moved
* @param x The x coordinate
* @param y The y coordinate
*/
def onMoveNode(node: Nodal, x:Double, y:Double): Unit

/**
* Defines what to do when a node is destroyed
*
Expand Down
2 changes: 2 additions & 0 deletions hypedyn-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ dependencies {
// For serialisation to JSON (save/load/export)
compile "org.json4s:json4s-native_${rootProject.majorScalaVersion}:3.3.0"

compile "com.lihaoyi:fastparse_2.11:0.3.6"

compile "commons-io:commons-io:2.4"

compile "org.fxmisc.easybind:easybind:1.0.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.narrativeandplay.hypedyn.story.internal.Story
import org.narrativeandplay.hypedyn.story.rules.{ActionDefinitions, ConditionDefinitions, Fact}
import org.narrativeandplay.hypedyn.undo._
import org.narrativeandplay.hypedyn.utils.parsing.SchemeParser

/**
* Main event dispatcher for the core
*/
Expand Down Expand Up @@ -189,7 +188,11 @@ object CoreEventDispatcher {

EventBus.ImportFromFileEvents foreach { evt =>
val dataToImport = IoController read evt.file
val story:Story = SchemeParser.parse(dataToImport)
val parseResult = SchemeParser.parse(dataToImport)
val story = parseResult("story").asInstanceOf[Story]
val pluginData = parseResult("plugins").asInstanceOf[AstMap]

Console.println(pluginData.toString)

StoryController.load(story)

Expand All @@ -199,6 +202,7 @@ object CoreEventDispatcher {
UndoController.markCurrentPosition()

EventBus.send(StoryLoaded(StoryController.story, CoreEventSourceIdentity))
EventBus.send(DataLoaded(pluginData.toMap, CoreEventSourceIdentity))
EventBus.send(FileLoaded(loadedFile, CoreEventSourceIdentity))
}

Expand Down
Loading

0 comments on commit 2c4baa9

Please sign in to comment.