First batch of schema fixes

- Allow for variable substitution in filter tags (mostly)
- Fix real not matching numbers like .5
- Support x,y=recall,recall

After this commit, there are no schema errors in the tutorial.
This commit is contained in:
Celtic Minstrel 2018-03-30 19:32:18 -04:00
parent 703d0c3cf4
commit a1ecf1a559
8 changed files with 36 additions and 25 deletions

View file

@ -325,8 +325,8 @@
max=infinite
super="$filter_unit"
{INSERT_TAG}
{SIMPLE_KEY to_x s_int}
{SIMPLE_KEY to_y s_int}
{SIMPLE_KEY to_x range_list}
{SIMPLE_KEY to_y range_list}
{SIMPLE_KEY to_location string}
{DEFAULT_KEY fire_event s_bool no}
{DEFAULT_KEY check_passability s_bool yes}

View file

@ -5,13 +5,13 @@
{SIMPLE_KEY time_of_day string}
{SIMPLE_KEY time_of_day_id string}
{SIMPLE_KEY terrain terrain_list}
{SIMPLE_KEY x range_list}
{SIMPLE_KEY y range_list}
{SIMPLE_KEY x s_coordinates}
{SIMPLE_KEY y s_coordinates}
{SIMPLE_KEY area string}
{SIMPLE_KEY include_borders bool}
{SIMPLE_KEY include_borders s_bool}
{DEPRECATED_KEY owner_side range_list}
{SIMPLE_KEY find_in string}
{SIMPLE_KEY radius int}
{SIMPLE_KEY radius s_int}
{SIMPLE_KEY formula formula}
{SIMPLE_KEY lua_function string}
{SIMPLE_KEY location_id string}
@ -28,6 +28,6 @@
name="$filter_adjacent_location"
max=0
super="$filter_location"
{SIMPLE_KEY count int}
{SIMPLE_KEY count s_int}
{SIMPLE_KEY adjacent dir_list}
[/tag]

View file

@ -19,6 +19,6 @@
name="$filter_vision"
max=0
super="$filter_side"
{DEFAULT_KEY visible bool yes}
{DEFAULT_KEY respect_fog bool yes}
{DEFAULT_KEY visible s_bool yes}
{DEFAULT_KEY respect_fog s_bool yes}
[/tag]

View file

@ -14,14 +14,14 @@
{SIMPLE_KEY status string}
{SIMPLE_KEY side range_list}
{DEPRECATED_KEY has_weapon string}
{SIMPLE_KEY canrecruit bool}
{SIMPLE_KEY canrecruit s_bool}
{SIMPLE_KEY gender gender}
{SIMPLE_KEY role string}
{SIMPLE_KEY level range_list}
{SIMPLE_KEY defense int}
{SIMPLE_KEY movement_cost int}
{SIMPLE_KEY x range_list}
{SIMPLE_KEY y range_list}
{SIMPLE_KEY defense s_int}
{SIMPLE_KEY movement_cost s_int}
{SIMPLE_KEY x s_coordinates}
{SIMPLE_KEY y s_coordinates}
{SIMPLE_KEY find_in string}
{SIMPLE_KEY formula formula}
{SIMPLE_KEY lua_function string}
@ -44,7 +44,7 @@
name="$filter_adjacent"
max=0
super="$filter_unit"
{SIMPLE_KEY count int}
{SIMPLE_KEY count s_int}
{SIMPLE_KEY adjacent dir_list}
{SIMPLE_KEY is_enemy bool}
{SIMPLE_KEY is_enemy s_bool}
[/tag]

View file

@ -8,10 +8,10 @@
{SIMPLE_KEY special string}
{SIMPLE_KEY special_active string}
{SIMPLE_KEY formula formula}
{SIMPLE_KEY damage int}
{SIMPLE_KEY number int}
{SIMPLE_KEY parry int}
{SIMPLE_KEY accuracy int}
{SIMPLE_KEY movement_used int}
{SIMPLE_KEY damage s_int}
{SIMPLE_KEY number s_int}
{SIMPLE_KEY parry s_int}
{SIMPLE_KEY accuracy s_int}
{SIMPLE_KEY movement_used s_int}
{FILTER_BOOLEAN_OPS weapon}
[/tag]

View file

@ -77,7 +77,6 @@
[/type]
[type]
name=range_list
# value="\d+(-\d+)?(,\d+(-\d+)?)*"
[list]
[element]
[list]
@ -85,7 +84,7 @@
min=1
max=2
[element]
link="int"
link=unsigned
[/element]
[/list]
[/element]
@ -354,6 +353,18 @@
name="micro_ai_action"
value="add|delete|change"
[/type]
[type]
name="coordinates"
[union]
[type]
link=range_list
[/type]
[type]
value="recall"
[/type]
[/union]
[/type]
{SUBST_TYPE coordinates}
[tag]
name="root"
min=1

View file

@ -21,7 +21,7 @@
[/type]
[type]
name=real
value="-?\d+(\.\d+)?"
value="-?\d+(\.\d+)?|-?\.\d+"
[/type]
[type]

View file

@ -56,7 +56,7 @@ std::shared_ptr<class_type> class_type::from_config(const config& cfg)
int list_min = list_cfg["min"].to_int();
int list_max = list_cfg["max"].str() == "infinite" ? -1 : list_cfg["max"].to_int(-1);
if(list_max < 0) list_max = INT_MAX;
type = std::make_shared<class_type_list>(cfg["name"], list_cfg["split"].str(","), list_min, list_max);
type = std::make_shared<class_type_list>(cfg["name"], list_cfg["split"].str("\\s*,\\s*"), list_min, list_max);
composite_range.emplace(list_cfg.child_range("element"));
} else if(cfg.has_attribute("value")) {
type = std::make_shared<class_type_simple>(cfg["name"], cfg["value"]);