Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PayrollParser parseAll returning RuntimeException #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lopezavila85 opened this issue Mar 21, 2016 · 5 comments
Closed

PayrollParser parseAll returning RuntimeException #18

lopezavila85 opened this issue Mar 21, 2016 · 5 comments

Comments

@lopezavila85
Copy link

Hello,

I have run the PayrollUseCases example ("The Parthenon Architecture" section).
However, the toDeduction method throws a

java.lang.RuntimeException: No result when parsing failed

I suspect it could be due to the locale on my computer (ES, Spanish), as the decimal places are separated with a comma, not a point. The rule String passed to the toDeduction method is:

biweekly {
      federal tax          20,000000  percent,
      state tax            5,000000  percent,
      insurance premiums   200,000000  dollars,
      retirement savings   5,000000  percent
    }

So the parseAll method does not retrieve anything at all. The full stack trace:

java.lang.RuntimeException: No result when parsing failed at scala.sys.package$.error(package.scala:27) at scala.util.parsing.combinator.Parsers$NoSuccess.get(Parsers.scala:176) at scala.util.parsing.combinator.Parsers$NoSuccess.get(Parsers.scala:162) at progscala2.appdesign.parthenon.PayrollParthenon$.progscala2$appdesign$parthenon$PayrollParthenon$$toDeduction(PayrollUseCases.scala:33) at progscala2.appdesign.parthenon.PayrollParthenon$$anonfun$processRules$2.apply(PayrollUseCases.scala:42) at progscala2.appdesign.parthenon.PayrollParthenon$$anonfun$processRules$2.apply(PayrollUseCases.scala:41) at scala.collection.TraversableLike$WithFilter$$anonfun$map$2.apply(TraversableLike.scala:728) at scala.collection.Iterator$class.foreach(Iterator.scala:742) at scala.collection.AbstractIterator.foreach(Iterator.scala:1194) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:727) at progscala2.appdesign.parthenon.PayrollParthenon$.processRules(PayrollUseCases.scala:41) at progscala2.appdesign.parthenon.PayrollParthenon$.main(PayrollUseCases.scala:72) at progscala2.appdesign.parthenon.PayrollParthenon.main(PayrollUseCases.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) [trace] Stack trace suppressed: run last compile:runMain for the full output.

Regards,

Álvaro López

@deanwampler
Copy link
Owner

You're probably right. Thanks for reporting it.

dean

@lopezavila85
Copy link
Author

I don't know if it would be possible to change the locale "on the go" of the Scala REPL. I have already had a similar problem converting from string to double and vice versa in other languages, such as C++.

@deanwampler
Copy link
Owner

I would just modify the code to use your locale. A good DSL should support local conventions. I didn't go that far for this simple example, but you could modify it as you want. The code should really make API calls to determine local conventions for number formatting, etc. and expect the user-supplied DSL code to use those conventions.

@deanwampler
Copy link
Owner

@lopezavila85 see the PR #42 that I just merged, which explicitly sets the locale in build.sbt. Does that fix your issue? Thanks.

@deanwampler
Copy link
Owner

Closing this one as it should be resolved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants