Skip to content

hansdejong/xml-parser-scalajs

Repository files navigation

This is a simple XML-parser for Scala / Scala.js.

I made it because I wanted to move some Java applets using XML to Scala.js.
Native Scala XML-support didn't seem flexible enough.
(Scala.js compiles Scala-code to Javascript but can't handle Java-code and -libraries. Scala itself often uses Java-libraries.)
At first I tried to use FastParse. I made an XML-parser with it, and one for evaluating Double-expressions, but couldn't fix some problems.

This time I ported a regex-Python-Lexer to Scala and extended it to produce a hierarchical Scala-datastructure.

I made it in Ammonite. To check it out, just install Ammonite, and run amm -w P1_opstart.sc on it. It is easy to build into a Scala-application. It is tested on the provided listing in Scala.js (that was a tense moment, using regex in Javascript).
(I'm not sure how easy it is to run Ammonite under Windows.)

The interfacing was immature but improved in the last commit: level is a var now, and can be adjusted after rearrangements, and namespaces are separated from tagnames. The example-code shows you a direction how to use it.
I intend to also show a Scala.js app using it on my blog. Working on it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published