@@ -19,6 +19,7 @@ package dalculator.translator
1919
2020import dalculator .cli .DalculatorParameters
2121import dalculator .model ._
22+ import dalculator .utils .Configuration
2223import theory .pb .solver .{OpbSolver , Sat4jBoth , Sat4jCP , Sat4jRes }
2324
2425import java .io .{FileNotFoundException , FileReader }
@@ -45,10 +46,10 @@ object ModelParser extends RegexParsers {
4546 def qident : Parser [String ] = " '" ~> ident <~ " '"
4647
4748 /** Rule for a minmal cut set (a list of quoted identifiers). */
48- def cut : Parser [FailureModeList ] = (" {" ~> repsep(qident, " ," ) <~ " }" ) ^^ (l => FailureModeList (l.map(f => FailureMode (f))))
49+ def cut ( implicit conf : Configuration ) : Parser [FailureModeList ] = (" {" ~> repsep(qident, " ," ) <~ " }" ) ^^ (l => FailureModeList (l.map(f => FailureMode (f))))
4950
5051 /** Rule for lists of minimal cut sets */
51- def cuts : Parser [List [FailureModeList ]] = rep(cut)
52+ def cuts ( implicit conf : Configuration ) : Parser [List [FailureModeList ]] = rep(cut)
5253
5354 /** Rule for minimal cut sets header, contains name. */
5455 def fcname : Parser [String ] = " products(MCS(" ~> qident <~ " ))" ~ " ="
@@ -63,7 +64,7 @@ object ModelParser extends RegexParsers {
6364 * @param xSev the given xSev value is assigned to the parsed FC
6465 * @param refDal the given refDal is assigned to the parsed FC
6566 * */
66- def fc (model : Model , nSev : Int , xSev : BigDecimal , refDal : DalLevel ): Parser [Model ] = opt(comment) ~> fcname ~ cuts <~ " end" ~ opt(comment) ^^ {
67+ def fc (model : Model , nSev : Int , xSev : BigDecimal , refDal : DalLevel )( implicit conf : Configuration ) : Parser [Model ] = opt(comment) ~> fcname ~ cuts <~ " end" ~ opt(comment) ^^ {
6768 case name ~ cuts =>
6869 model.add(FailureCondition (name, nSev, xSev, cuts, refDal))
6970 model
@@ -76,7 +77,7 @@ object ModelParser extends RegexParsers {
7677 * @param xSev the given xSev value is assigned to the parsed FC
7778 * @param refDal the given refDal is assigned to the parsed FC
7879 */
79- def loadFC (filename : String , model : Model , nSev : Int , xSev : BigDecimal , refDal : DalLevel ): Unit = {
80+ def loadFC (filename : String , model : Model , nSev : Int , xSev : BigDecimal , refDal : DalLevel )( implicit conf : Configuration ) : Unit = {
8081 val reader = try {
8182 new FileReader (filename)
8283 } catch {
@@ -310,24 +311,24 @@ object ModelParser extends RegexParsers {
310311 }
311312
312313 /** Rule for user defined lambda bounds declaration */
313- def lambdaBounds : Parser [UserDefinedConstraint ] = (" LambdaBounds(" ~> qident ~ " ," ~ decimal ~ " ," ~ decimal <~ " )" ) ^^ {
314+ def lambdaBounds ( implicit conf : Configuration ) : Parser [UserDefinedConstraint ] = (" LambdaBounds(" ~> qident ~ " ," ~ decimal ~ " ," ~ decimal <~ " )" ) ^^ {
314315 case fm ~ _ ~ l ~ _ ~ u =>
315316 LambdaBoundsCstr (FailureMode (fm), l, u)
316317 }
317318
318319 /** Rule for user defined latent failure mode declarations */
319- def latent : Parser [UserDefinedConstraint ] = (" Latent(" ~> qident <~ " )" ) ^^ (fm => LatentCstr (FailureMode (fm)))
320+ def latent ( implicit conf : Configuration ) : Parser [UserDefinedConstraint ] = (" Latent(" ~> qident <~ " )" ) ^^ (fm => LatentCstr (FailureMode (fm)))
320321
321322 /** Rule for user defined latent failure mode declarations with special interval checks */
322- def latentItv : Parser [UserDefinedConstraint ] = (" Latent(" ~> qident ~ " ," ~ repsep(integer, " ," ) <~ " )" ) ^^ {
323+ def latentItv ( implicit conf : Configuration ) : Parser [UserDefinedConstraint ] = (" Latent(" ~> qident ~ " ," ~ repsep(integer, " ," ) <~ " )" ) ^^ {
323324 case fm ~ _ ~ itvs => LatentCstr (FailureMode (fm), Some (itvs))
324325 }
325326
326327 /** Disjunction of user defined constraints */
327- def usrDefCtr : Parser [UserDefinedConstraint ] = alloc | coloc | indep | notindep | noneIndep | dalBound | aircraftData | lambdaBounds | latent | latentItv | optimisation | dalRule | maxCost | minCost | DalCost | dalBoundqIdent
328+ def usrDefCtr ( implicit conf : Configuration ) : Parser [UserDefinedConstraint ] = alloc | coloc | indep | notindep | noneIndep | dalBound | aircraftData | lambdaBounds | latent | latentItv | optimisation | dalRule | maxCost | minCost | DalCost | dalBoundqIdent
328329
329330 /** Rule for user defined constraints file */
330- def usrDefCtrs (c : UserDefinedConstraints ): Parser [UserDefinedConstraints ] = opt(rep(usrDefCtr | comment)) ^^ {
331+ def usrDefCtrs (c : UserDefinedConstraints )( implicit conf : Configuration ) : Parser [UserDefinedConstraints ] = opt(rep(usrDefCtr | comment)) ^^ {
331332 constraints => {
332333 if (constraints.isDefined)
333334 constraints.get collect {case cst: UserDefinedConstraint => cst} foreach c.add
@@ -336,7 +337,7 @@ object ModelParser extends RegexParsers {
336337 }
337338
338339 /** Loads the given user defined constraints file. */
339- def loadUDef (filename : String , c : UserDefinedConstraints ): Unit = {
340+ def loadUDef (filename : String , c : UserDefinedConstraints )( implicit conf : Configuration ) : Unit = {
340341 val reader = try {
341342 val reader = new FileReader (filename)
342343 reader
0 commit comments