Supporting Units in SMTK's Attribute Resource

I wrote a simple PEGTL parser written on Saturday that can be used to prevent ambiguous/confusing expressions that udunits2’s parser accepts. It is here for anyone curious.

You can compile it by placing it in SMTK’s source tree and pointing it to your cmb-superbuild like so:

 c++ -g -O0 -Wall -Wextra -std=c++14 \
  -I. -I../src -I /path/to/superbuild/install/include/ \
  -I /usr/include/udunits2 \
  -isystem /usr/include/qt5 \
  -isystem /usr/include/qt5/QtWidgets \
  -isystem /usr/include/qt5/QtGui \
  -isystem /usr/include/qt5/QtCore \
  -L /usr/lib64/qt5 -lQt5Gui -lQt5Widgets -lQt5Core \
  -ludunits2 -o unit-parser-proto \
  ../src/unit-parser-proto.cxx

As you can see when you run it, it will attempt to parse what you type into a QLineEdit and change the background color to

  • pink when there’s a parse failure
  • red when units are parsed but do not conform to length.

It also prints a bunch of debug crud to the console.