Thursday, October 13, 2016

Policy Plus - SPOL parser

A couple days ago, I started writing a parser for a new Semantic Policy format. Today I filled out the part that loads the data for extra options. It figures out the type automatically, without needing to check the actual policy definition.

  • Enum selected indices are the number prefixed with the pound sign, like #2
  • Normal numbers are just the number, like 45
  • Checkbox check states are Boolean-naming strings, True or False
  • Text box contents are the string surrounded by single quotes with no escaping needed, like 'I can't do that'
  • Multi-valued text box contents are the double-quoted separated by commas, double quotes escaped by doubling if necessary, like "Thing 1", "I said ""wow!"""
  • Lists (non-dictionary) are double-quoted strings, one per line, surrounded by square brackets
  • Dictionary-like lists are the same as normal lists but with two strings on each line, one for the key, one for the value
An empty list and an empty dictionary look the same but are different types, so the parser just turns them both into Nothing, which is ignored by PolicyProcessing instead of causing an invalid cast.

Once I throw together a UI for importing SPOLs, I'll be able to test this parser.

No comments:

Post a Comment