Skip to content

Instantly share code, notes, and snippets.

@adridadou
Created June 5, 2016 10:29
Show Gist options
  • Save adridadou/178a88db18adf79d08cb858e359ea426 to your computer and use it in GitHub Desktop.
Save adridadou/178a88db18adf79d08cb858e359ea426 to your computer and use it in GitHub Desktop.
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)
}
}
@adridadou
Copy link
Author

[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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment