# Supporting Units in SMTK's Attribute Resource

**URL:** https://discourse.kitware.com/t/supporting-units-in-smtks-attribute-resource/984
**Category:** Design
**Created:** [February 22, 2023, 10:05pm UTC](https://discourse.kitware.com/t/supporting-units-in-smtks-attribute-resource/984 "2023-02-22T22:05:08Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)
#### Post date: [March 16, 2023, 1:34am UTC](https://discourse.kitware.com/t/supporting-units-in-smtks-attribute-resource/984/10 "2023-03-16T01:34:31Z")

</div>

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](https://data.kitware.com/api/v1/item/641271d87b0dfcc98f66bb00/download) for anyone curious.

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

```plaintext
 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.

---

_[View the full topic](https://discourse.kitware.com/t/supporting-units-in-smtks-attribute-resource/984)._
