Tuesday, August 25, 2020

v1.1 update

Summary

The update brings a conservative stream reading feature, a few minor library usage changes, and some performance improvements.

Conservative stream reading

When exposing formulas for modding, you are probably going to have them as a part of a larger structured text file, like XML, JSON, INI, CSV, or your own DSL. In most cases you could use the syntax of the "outer" document to find out where each formula begins and ends but with this update, that is not entirely necessary.

The Formula Parser can work with two kinds of inputs: a string and a text stream. With a string, the parser assumes the whole input should be one valid formula while with a stream the parser tries to be conservative. This is a new feature where it assumes a formula starts at the current position in the stream and that there can be more data after the formula ends. Consider this input:

2+x a:4

Here the parser would read "2+x", look for another operator symbol, notice there is none (read whitespace and peek "a") and leave "a:4" in the stream. With this feature, you can make a domain-specific language with very light syntax where formulas are not enclosed by any particular symbols and can span multiple lines


No comments:

Post a Comment

v1.1 update

Summary The update brings a conservative stream reading feature, a few minor library usage changes, and some performance improvements. Conse...