# Copyright 2005 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ ? def defineException := # value: ? def makeParseError := defineException( > ["org.cubik.cle.parser.makeLALR1Parser$ParseError"], > def pePrinter implements DeepFrozen { > to run(tw :TextWriter, [=> found, => expected]) :void { > tw.write("expected one of ") > tw.quote(expected.getElements()) > tw.write(", got ") > tw.quote(found) > }}) # value: ? def e := makeParseError(["found" => "{", "expected" => [";"].asSet()]) # value: problem: expected one of [";"], got "{" ? e.getExpected() # value: [";"].asSet() ? def defineExceptionGuard := # value: ? def ParseError := defineExceptionGuard(["org.cubik.cle.parser.makeLALR1Parser$ParseError"]) # value: ParseError ? "foo" :ParseError # problem: the String "foo" doesn't coerce to an e-structure-exception XXX possible error change later ? e :ParseError # value: problem: expected one of [";"], got "{" ? e.getFound() # value: "{" ? defineException([], def _(_,_):void{})([].asMap()) :ParseError # problem: <_> is not DeepFrozen x ? def CoercionFailure := x # value: CoercionFailure x x ? CoercionFailure.accepts(Ref.optProblem(Ref.broken("X"))) x # value: false x x ? def typeError :CoercionFailure := escape ex { String.coerce(0, ex) } x # value: problem: the int 0 doesn't coerce to a String x x ? typeError.getSpecimen() x # value: 0 x x ? typeError.getGuard() x # value: String x