xgi.ut.dsl.interpreters.ext.ScenarioInterpretation.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of UT_DSL_PARSING Show documentation
Show all versions of UT_DSL_PARSING Show documentation
This module contains the scala parsers that parses + interpret the dsl
The newest version!
/*
* ScenarLang a domain specific language that attempts to make it even easier
* to write unit tests with mockito
*
* Copyright (C) 2012 X. Gillard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package xgi.ut.dsl.interpreters.ext
import xgi.ut.dsl.ScenarParsers
import xgi.ut.dsl.interpreters.ScenarioInterpreter
import java.io.File
import scala.io.Source
import scala.collection.mutable.StringBuilder
import scala.collection.immutable.VectorBuilder
import scala.collection.mutable.Map
import scala.collection.JavaConversions
/**
* this class will let you interpret any given scenario
*/
class ScenarioInterpretation(val context:Any, val scripts:Array[File], val variables:Map[String, Any]) extends ScenarParsers with ScenarioInterpreter {
def this(ctx:Any, scripts:Array[File], vars:java.util.Map[String, Any]) = this(ctx, scripts, JavaConversions.mapAsScalaMap[String, Any](vars))
val texts = for(script <- scripts) yield { ("" /: Source.fromFile(script).getLines)((a, b) => a+"\n"+b) }
texts foreach {text => parseScenario(text) foreach interpret}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy