Created
June 5, 2016 10:29
-
-
Save adridadou/178a88db18adf79d08cb858e359ea426 to your computer and use it in GitHub Desktop.
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
class ClauseParser (val input: ParserInput, val parameters:Map[String,ContractField]) extends Parser with StringBuilding{ | |
val openS = "{{" | |
val closeS = "}}" | |
def clause: Rule1[Clause] = rule { Parameters ~ Text ~ EOI ~> ((parameters, text) => Clause(text, parameters))} | |
def Parameter:Rule1[(String,ContractField)] = rule { | |
ID ~ ':' ~ ID ~> (createParameterPair(_,_)) | |
} | |
def Parameters: Rule1[Map[String,ContractField]] = rule { | |
oneOrMore(Parameter).separatedBy('\n') ~ "###" ~> (_.toMap) | |
} | |
def ID:Rule1[String] = rule { | |
oneOrMore(CharPredicate.AlphaNum) ~ push(sb.toString) | |
} | |
def Text: Rule1[String] = rule { | |
oneOrMore(CharPredicate.All) ~push(sb.toString) | |
} | |
private def createParameterPair(name:String, parameterType:String):(String,ContractField) = name -> toParameterType(parameterType) | |
private def toParameterType(name:String):ContractField = name match { | |
case "FullName" => FullName | |
case "Address" => Address | |
case "Date" => ContractDate | |
case _ => Unknown(name) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[error] /Users/davidroon/projects/openlegal-markup/src/main/scala/org/adridadou/clause/Clause.scala:19: missing parameter type
[error] def clause: Rule1[Clause] = rule { Parameters ~ Text ~ EOI ~> ((parameters, text) => Clause(text, parameters))}
[error] ^
[error] /Users/davidroon/projects/openlegal-markup/src/main/scala/org/adridadou/clause/Clause.scala:19: missing parameter type
[error] def clause: Rule1[Clause] = rule { Parameters ~ Text ~ EOI ~> ((parameters, text) => Clause(text, parameters))}
[error] ^
[error] /Users/davidroon/projects/openlegal-markup/src/main/scala/org/adridadou/clause/Clause.scala:26: missing parameter type for expanded function ((x$3) => x$3.toMap)
[error] oneOrMore(Parameter).separatedBy('\n') ~ "###" ~> (_.toMap)