Chapter 13. Context Variable

Use a variable to hold context required during a parse.


Imagine you are parsing a list of items, capturing data about each one. Each bit of information about an item can be captured independently, but you also need to know which particular item you are capturing information for.

A Context Variable does this by keeping the current item in a variable and reassigning it as you move to a new one.

13.1 How It Works

You have a Context Variable whenever you have a variable named something like currentItem which you update periodically during the parse as you move from one item to another in the input script.

A Context ...

Get Domain Specific Languages now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.