# Expression Parsing?

**URL:** <https://forum.inductiveautomation.com/t/expression-parsing/9170>\
**Category:** Module Development\
**Created:** [October 13, 2014, 2:15pm UTC](https://forum.inductiveautomation.com/t/expression-parsing/9170 "2014-10-13T14:15:40Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 20, 2014, 3:58pm UTC](https://forum.inductiveautomation.com/t/expression-parsing/9170/7 "2014-10-20T15:58:08Z")

</div>

This may be all you need:

```auto
public class ExampleParseContext implements ExpressionParseContext {

    private final TagManagerBase tagManagerBase;
    private final FunctionFactory functionFactory;

    public ExampleParseContext(TagManagerBase tagManagerBase, FunctionFactory functionFactory) {
        this.tagManagerBase = tagManagerBase;
        this.functionFactory = functionFactory;
    }

    @Override
    public Expression createBoundExpression(String path) throws RuntimeException {
        try {
            TagPath tagPath = TagPathParser.parse(path);
            Tag tag = tagManagerBase.getTag(tagPath);

            if (tag == null) throw new TagNotFoundException(tagPath);

            TagValue tagValue = tag.getAttribute(tagPath.getProperty());

            TagListener listener = new TagListener(
                    tagPath,
                    tagValue.getValue(),
                    tagValue.getQuality()
            );

            Class type = TagProp.Value.equals(tagPath.getProperty()) ?
                    tag.getDataType().getJavaType() :
                    tagPath.getProperty().getType();

            BoundTagExpression expression = new BoundTagExpression(tagPath);
            expression.setType(type);
            expression.setTagListenerDelegate(listener);

            return expression;
        } catch (IllegalArgumentException | IOException | TagNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public FunctionFactory getFunctionFactory() {
        return functionFactory;
    }

}
```

You can get references to the FunctionFactory and to the SQLTagsManager from GatewayContext. See GatewayContext#getExpressionFunctionFactory() and GatewayContext#getTagManager().

---

_[View the full topic](https://forum.inductiveautomation.com/t/expression-parsing/9170)._
