Skip to content

Commit c3a2ba6

Browse files
committed
Refactored definition of all custom tokens.
1 parent 035eae8 commit c3a2ba6

File tree

4 files changed

+139
-143
lines changed

4 files changed

+139
-143
lines changed

source/code/systems/input_action_system/private/input_action_dsl.cxx

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,47 +52,47 @@ namespace ice
5252

5353
static constexpr ice::TokenInfo Constant_Tokens[]{
5454
{ "action", TokenType::ASL_KW_Action },
55-
{ "active", ice::grammar::UCT_WhenActive },
56-
{ "activate", ice::grammar::UCT_StepActivate },
55+
{ "active", TokenType::ASL_OP_IsActive },
56+
{ "activate", TokenType::ASL_OP_Activate },
5757
//{ "accumulated", ice::grammar::UCT_ActionFlagAccumulated },
58-
{ "deactivate", ice::grammar::UCT_StepDeactivate },
59-
{ "and", ice::grammar::UCT_WhenAnd },
58+
{ "deactivate", TokenType::ASL_OP_Deactivate },
59+
{ "and", TokenType::ASL_KW_WhenAnd },
6060
{ "axis1d", TokenType::ASL_NT_Axis1D },
6161
{ "axis2d", TokenType::ASL_NT_Axis2D },
6262
{ "axis3d", TokenType::ASL_NT_Axis3D },
63-
{ "bool", ice::grammar::UCT_ActionTypeBool },
64-
{ "button", ice::grammar::UCT_InputTypeButton },
65-
{ "inactive", ice::grammar::UCT_WhenInactive },
66-
{ "float1", ice::grammar::UCT_ActionTypeFloat1 },
67-
{ "float2", ice::grammar::UCT_ActionTypeFloat2 },
68-
{ "float3", ice::grammar::UCT_ActionTypeFloat3 },
63+
{ "button", TokenType::ASL_NT_Button },
64+
{ "inactive", TokenType::ASL_OP_IsInactive },
65+
{ "bool", TokenType::ASL_NT_Bool },
66+
{ "float1", TokenType::ASL_NT_Float1 },
67+
{ "float2", TokenType::ASL_NT_Float2 },
68+
{ "float3", TokenType::ASL_NT_Float3 },
6969
// { "gamepad", ice::grammar::UCT_InputBindingPad },
7070
// { "gctrl", ice::grammar::UCT_InputBindingPad },
7171
//{ "km", ice::grammar::UCT_InputBindingKeyboard },
72-
{ "kb", ice::grammar::UCT_InputBindingKeyboard },
72+
{ "kb", TokenType::ASL_KW_Keyboard },
7373
//{ "keymod", ice::grammar::UCT_InputBindingKeyboard },
74-
{ "key", ice::grammar::UCT_InputBindingKeyboard },
74+
{ "key", TokenType::ASL_KW_Keyboard },
7575
// { "keyboard", ice::grammar::UCT_InputBindingKeyboard },,
76-
{ "max", ice::grammar::UCT_ModifierOpMax },
77-
{ "min", ice::grammar::UCT_ModifierOpMin },
78-
{ "mouse", ice::grammar::UCT_InputBindingMouse },
79-
{ "mp", ice::grammar::UCT_InputBindingMouse },
80-
{ "gamepad", ice::grammar::UCT_InputBindingPad },
81-
{ "gp", ice::grammar::UCT_InputBindingPad },
76+
{ "max", TokenType::ASL_OP_Max },
77+
{ "min", TokenType::ASL_OP_Min },
78+
{ "mouse", TokenType::ASL_KW_Mouse },
79+
{ "mp", TokenType::ASL_KW_Mouse },
80+
{ "gamepad", TokenType::ASL_KW_Controller },
81+
{ "gp", TokenType::ASL_KW_Controller },
8282
{ "layer", TokenType::ASL_KW_Layer },
83-
{ "object", ice::grammar::UCT_ActionTypeObject },
84-
{ "or", ice::grammar::UCT_WhenOr },
85-
{ "once", ice::grammar::UCT_ActionFlagOnce },
86-
{ "pressed", ice::grammar::UCT_WhenPressed },
87-
{ "released", ice::grammar::UCT_WhenReleased },
83+
{ "object", TokenType::ASL_NT_Object },
84+
{ "or", TokenType::ASL_KW_WhenOr },
85+
{ "once", TokenType::ASL_KWF_Once },
86+
{ "pressed", TokenType::ASL_OP_IsPressed },
87+
{ "released", TokenType::ASL_OP_IsReleased },
8888
{ "source", TokenType::ASL_KW_Source },
89-
{ "toggled", ice::grammar::UCT_ActionFlagToggled },
90-
{ "toggle", ice::grammar::UCT_StepToggle },
91-
{ "when", ice::grammar::UCT_When },
92-
{ "reset", ice::grammar::UCT_StepReset },
93-
{ "series", ice::grammar::UCT_WhenFlagCheckSeries },
94-
{ "time", ice::grammar::UCT_StepTime },
95-
{ "mod", ice::grammar::UCT_Modifier },
89+
{ "toggled", TokenType::ASL_KWF_Toggled },
90+
{ "toggle", TokenType::ASL_OP_Toggle },
91+
{ "when", TokenType::ASL_KW_When },
92+
{ "reset", TokenType::ASL_OP_Reset },
93+
{ "series", TokenType::ASL_KWF_CheckSeries },
94+
{ "time", TokenType::ASL_OP_Time },
95+
{ "mod", TokenType::ASL_KW_Modifier },
9696
};
9797

9898
//! \brief A default implementation of a tokenizer for Arctic language.

source/code/systems/input_action_system/private/input_action_dsl_grammar.hxx

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ namespace ice::grammar
2727
};
2828

2929
static constexpr SyntaxRule Rule_LayerSourceBindingDeviceRules[]{
30-
SyntaxRule{ UCT_InputBindingKeyboard },
31-
SyntaxRule{ UCT_InputBindingMouse },
32-
SyntaxRule{ UCT_InputBindingPad },
30+
SyntaxRule{ TokenType::ASL_KW_Controller },
31+
SyntaxRule{ TokenType::ASL_KW_Keyboard },
32+
SyntaxRule{ TokenType::ASL_KW_Mouse },
3333
};
3434

3535
static constexpr SyntaxRule Rule_LayerSourceBindingRules[]{ // ': <dev>.<src>' or ', <dev>.<src>'
@@ -40,7 +40,7 @@ namespace ice::grammar
4040
};
4141

4242
static constexpr SyntaxRule Rule_LayerInputTypeRules[]{ // button, axis1d, axis2d or axis3d
43-
SyntaxRule{ UCT_InputTypeButton },
43+
SyntaxRule{ TokenType::ASL_NT_Button },
4444
SyntaxRule{ TokenType::ASL_NT_Axis1D },
4545
SyntaxRule{ TokenType::ASL_NT_Axis2D },
4646
SyntaxRule{ TokenType::ASL_NT_Axis3D },
@@ -98,11 +98,11 @@ namespace ice::grammar
9898
};
9999

100100
static constexpr SyntaxRule Rule_LayerActionStepBuiltInListRules[]{
101-
SyntaxRule{ UCT_StepActivate },
102-
SyntaxRule{ UCT_StepDeactivate },
103-
SyntaxRule{ UCT_StepToggle },
104-
SyntaxRule{ UCT_StepReset },
105-
SyntaxRule{ UCT_StepTime },
101+
SyntaxRule{ TokenType::ASL_OP_Activate },
102+
SyntaxRule{ TokenType::ASL_OP_Deactivate },
103+
SyntaxRule{ TokenType::ASL_OP_Toggle },
104+
SyntaxRule{ TokenType::ASL_OP_Reset },
105+
SyntaxRule{ TokenType::ASL_OP_Time },
106106
};
107107

108108
static constexpr SyntaxRule Rule_LayerActionStepArithmeticOperationRules[]{
@@ -152,10 +152,10 @@ namespace ice::grammar
152152
};
153153

154154
static constexpr SyntaxRule Rule_LayerActionWhenTargetActionConditionListRules[]{
155-
SyntaxRule{ UCT_WhenPressed },
156-
SyntaxRule{ UCT_WhenReleased },
157-
SyntaxRule{ UCT_WhenActive },
158-
SyntaxRule{ UCT_WhenInactive },
155+
SyntaxRule{ TokenType::ASL_OP_IsPressed },
156+
SyntaxRule{ TokenType::ASL_OP_IsReleased },
157+
SyntaxRule{ TokenType::ASL_OP_IsActive },
158+
SyntaxRule{ TokenType::ASL_OP_IsInactive },
159159
SyntaxRule{ TokenType::KW_True },
160160
};
161161

@@ -190,28 +190,27 @@ namespace ice::grammar
190190
};
191191

192192
static constexpr SyntaxRule Rule_LayerActionWhenBlockRules[]{
193-
SyntaxRule{ UCT_When },
194-
SyntaxRule{ UCT_WhenAnd },
195-
SyntaxRule{ UCT_WhenOr },
193+
SyntaxRule{ TokenType::ASL_KW_When },
194+
SyntaxRule{ TokenType::ASL_KW_WhenAnd },
195+
SyntaxRule{ TokenType::ASL_KW_WhenOr },
196196
};
197197

198198
static constexpr SyntaxRule Rule_LayerActionFlagsListRules[]{
199-
SyntaxRule{ UCT_ActionFlagOnce, &syntax::LayerAction::flag_once },
200-
SyntaxRule{ UCT_ActionFlagToggled, &syntax::LayerAction::flag_toggled },
201-
//SyntaxRule{ UCT_ActionFlagAccumulated, &syntax::LayerAction::flag_accumulated },
199+
SyntaxRule{ TokenType::ASL_KWF_Once, &syntax::LayerAction::flag_once },
200+
SyntaxRule{ TokenType::ASL_KWF_Toggled, &syntax::LayerAction::flag_toggled },
202201
};
203202

204203
static constexpr SyntaxRule Rule_LayerActionFlagsRules[]{
205-
SyntaxRule{ grammar::TokenType::CT_Comma },
204+
SyntaxRule{ TokenType::CT_Comma },
206205
SyntaxRule{ Rule_LayerActionFlagsListRules, MatchFirst }
207206
};
208207

209208
static constexpr SyntaxRule Rule_LayerActionWhenFlagsListRules[]{
210-
SyntaxRule{ UCT_WhenFlagCheckSeries, &syntax::LayerActionWhen::flag_series }
209+
SyntaxRule{ TokenType::ASL_KWF_CheckSeries, &syntax::LayerActionWhen::flag_series }
211210
};
212211

213212
static constexpr SyntaxRule Rule_LayerActionWhenFlagsRules[]{
214-
SyntaxRule{ grammar::TokenType::CT_Comma },
213+
SyntaxRule{ TokenType::CT_Comma },
215214
SyntaxRule{ Rule_LayerActionWhenFlagsListRules, MatchFirst }
216215
};
217216

@@ -240,12 +239,12 @@ namespace ice::grammar
240239
SyntaxRule{ TokenType::OP_Mul },
241240
SyntaxRule{ TokenType::OP_Plus },
242241
SyntaxRule{ TokenType::OP_Minus },
243-
SyntaxRule{ UCT_ModifierOpMin },
244-
SyntaxRule{ UCT_ModifierOpMax },
242+
SyntaxRule{ TokenType::ASL_OP_Min },
243+
SyntaxRule{ TokenType::ASL_OP_Max },
245244
};
246245

247246
static constexpr SyntaxRule Rule_LayerActionModifierRules[]{
248-
SyntaxRule{ UCT_Modifier },
247+
SyntaxRule{ TokenType::ASL_KW_Modifier },
249248
SyntaxRule{ Rule_LayerActionModifierComponentRules, MatchAll },
250249
SyntaxRule{ Rule_LayerActionModifierOperationListRules, MatchFirst, &syntax::LayerActionModifier::operation },
251250
SyntaxRule{ Rule_LayerActionWhenParamNumberTokenListRules, MatchFirst, &syntax::LayerActionModifier::param },
@@ -257,11 +256,11 @@ namespace ice::grammar
257256
////////////////////////////////////////////////////////////////
258257

259258
static constexpr SyntaxRule Rule_LayerActionTypeRules[]{ // button, axis1d, axis2d or axis3d
260-
SyntaxRule{ UCT_ActionTypeBool },
261-
SyntaxRule{ UCT_ActionTypeFloat1 },
262-
SyntaxRule{ UCT_ActionTypeFloat2 },
263-
SyntaxRule{ UCT_ActionTypeFloat3 },
264-
SyntaxRule{ UCT_ActionTypeObject },
259+
SyntaxRule{ TokenType::ASL_NT_Bool },
260+
SyntaxRule{ TokenType::ASL_NT_Float1 },
261+
SyntaxRule{ TokenType::ASL_NT_Float2 },
262+
SyntaxRule{ TokenType::ASL_NT_Float3 },
263+
SyntaxRule{ TokenType::ASL_NT_Object },
265264
};
266265

267266
static constexpr SyntaxRule Rule_LayerActionRules[]{ // action <name>: <native_type>

source/code/systems/input_action_system/private/input_action_dsl_layer_builder.cxx

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ namespace ice
5757
ice::InputActionSourceType type = InputActionSourceType::Key;
5858
switch(node.data().type.type)
5959
{
60-
case ice::grammar::UCT_InputTypeButton: type = InputActionSourceType::Button; break;
60+
case TokenType::ASL_NT_Button: type = InputActionSourceType::Button; break;
6161
case TokenType::ASL_NT_Axis1D: type = InputActionSourceType::Axis1d; break;
6262
case TokenType::ASL_NT_Axis2D: type = InputActionSourceType::Axis2d; break;
63+
default: ICE_ASSERT_CORE(false); type = InputActionSourceType::Axis2d; break;
6364
}
6465

6566
ice::InputActionBuilder::Source source = _builder->define_source(node.data().name, type);
@@ -71,25 +72,15 @@ namespace ice
7172
using ice::input::KeyboardMod;
7273
using ice::input::MouseInput;
7374

74-
if (binding.data().device.type == ice::grammar::UCT_InputBindingKeyboard)
75+
if (binding.data().device.type == TokenType::ASL_KW_Keyboard)
7576
{
7677
ICE_ASSERT_CORE(type == InputActionSourceType::Key || type == InputActionSourceType::Button);
7778

78-
//ice::u64 const valsize = binding.data().device.value.size();
79-
//if (binding.data().device.value[valsize / 2] == 'm')
80-
//{
81-
// KeyboardMod const mod = detail::mod_from_dsl(binding.data().source);
82-
// ICE_ASSERT_CORE(mod != KeyboardMod::None);
83-
// source.add_keymod(mod);
84-
//}
85-
//else
86-
{
87-
KeyboardKey const key = detail::key_from_dsl(binding.data().source);
88-
ICE_ASSERT_CORE(key != KeyboardKey::Unknown);
89-
source.add_key(key);
90-
}
79+
KeyboardKey const key = detail::key_from_dsl(binding.data().source);
80+
ICE_ASSERT_CORE(key != KeyboardKey::Unknown);
81+
source.add_key(key);
9182
}
92-
else if (binding.data().device.type == ice::grammar::UCT_InputBindingMouse)
83+
else if (binding.data().device.type == TokenType::ASL_KW_Mouse)
9384
{
9485
MouseInput const mouseinput = detail::mouse_from_dsl(binding.data().source);
9586
ICE_ASSERT_CORE(
@@ -160,7 +151,7 @@ namespace ice
160151
using enum ice::InputActionCondition;
161152

162153
arctic::SyntaxNode<ice::syntax::LayerActionWhen> cond_node = node;
163-
ICE_ASSERT_CORE(cond_node.data().type.type == grammar::UCT_When);
154+
ICE_ASSERT_CORE(cond_node.data().type.type == TokenType::ASL_KW_When);
164155

165156
ICE_LOG(LogSeverity::Debug, LogTag::Tool, "New condition series");
166157
do
@@ -183,7 +174,7 @@ namespace ice
183174
flags |= InputActionConditionFlags::SeriesCheck;
184175
}
185176

186-
if (cond.type.type == grammar::UCT_WhenAnd)
177+
if (cond.type.type == TokenType::ASL_KW_WhenAnd)
187178
{
188179
flags |= InputActionConditionFlags::SeriesAnd;
189180
}
@@ -219,7 +210,7 @@ namespace ice
219210
}
220211

221212
cond_node = cond_node.sibling<ice::syntax::LayerActionWhen>();
222-
} while (cond_node && cond_node.data().type.type != grammar::UCT_When);
213+
} while (cond_node && cond_node.data().type.type != TokenType::ASL_KW_When);
223214

224215
// TODO: Check for '.continue' flag to skip setting 'Final' flag here
225216
//if (/* DOES NOT HAVE '.continue' flag */)
@@ -379,10 +370,10 @@ namespace ice
379370
switch (token.type)
380371
{
381372
// Action conditions
382-
case grammar::UCT_ActionTypeBool: return InputActionDataType::Bool;
383-
case grammar::UCT_ActionTypeFloat1: return InputActionDataType::Float1;
384-
case grammar::UCT_ActionTypeFloat2: return InputActionDataType::Float2;
385-
case grammar::UCT_ActionTypeObject: return InputActionDataType::ActionObject;
373+
case TokenType::ASL_NT_Bool: return InputActionDataType::Bool;
374+
case TokenType::ASL_NT_Float1: return InputActionDataType::Float1;
375+
case TokenType::ASL_NT_Float2: return InputActionDataType::Float2;
376+
case TokenType::ASL_NT_Object: return InputActionDataType::ActionObject;
386377
default: ICE_ASSERT_CORE(false); return InputActionDataType::Invalid;
387378
}
388379
}
@@ -392,19 +383,19 @@ namespace ice
392383
switch(token.type)
393384
{
394385
// Action conditions
395-
case grammar::UCT_WhenPressed: return InputActionCondition::Pressed;
396-
case grammar::UCT_WhenReleased: return InputActionCondition::Released;
397-
case grammar::UCT_WhenActive: return action_condition ? InputActionCondition::ActionToggleActive : InputActionCondition::Active;
398-
case grammar::UCT_WhenInactive: return InputActionCondition::ActionToggleInactive;
386+
case TokenType::ASL_OP_IsPressed: return InputActionCondition::Pressed;
387+
case TokenType::ASL_OP_IsReleased: return InputActionCondition::Released;
388+
case TokenType::ASL_OP_IsActive: return action_condition ? InputActionCondition::ActionToggleActive : InputActionCondition::Active;
389+
case TokenType::ASL_OP_IsInactive: return InputActionCondition::ActionToggleInactive;
399390
// Arithmetic conditions
400-
case arctic::TokenType::OP_Equal: return InputActionCondition::Equal;
401-
case arctic::TokenType::OP_NotEqual: return InputActionCondition::NotEqual; // TODO
402-
case arctic::TokenType::OP_Greater: return InputActionCondition::Greater;
403-
case arctic::TokenType::OP_GreaterOrEqual: return InputActionCondition::GreaterOrEqual;
404-
case arctic::TokenType::OP_Less: return InputActionCondition::Lower;
405-
case arctic::TokenType::OP_LessOrEqual: return InputActionCondition::LowerOrEqual;
391+
case TokenType::OP_Equal: return InputActionCondition::Equal;
392+
case TokenType::OP_NotEqual: return InputActionCondition::NotEqual; // TODO
393+
case TokenType::OP_Greater: return InputActionCondition::Greater;
394+
case TokenType::OP_GreaterOrEqual: return InputActionCondition::GreaterOrEqual;
395+
case TokenType::OP_Less: return InputActionCondition::Lower;
396+
case TokenType::OP_LessOrEqual: return InputActionCondition::LowerOrEqual;
406397
// Special conditions
407-
case arctic::TokenType::KW_True: return InputActionCondition::AlwaysTrue;
398+
case TokenType::KW_True: return InputActionCondition::AlwaysTrue;
408399
default: ICE_ASSERT_CORE(false); return InputActionCondition::Invalid;
409400
}
410401
}
@@ -413,15 +404,15 @@ namespace ice
413404
{
414405
switch(token.type)
415406
{
416-
case grammar::UCT_StepActivate: return InputActionStep::Activate;
417-
case grammar::UCT_StepDeactivate: return InputActionStep::Deactivate;
418-
case grammar::UCT_StepToggle: return InputActionStep::Toggle;
419-
case grammar::UCT_StepReset: return InputActionStep::Reset;
420-
case grammar::UCT_StepTime: return InputActionStep::Time;
407+
case TokenType::ASL_OP_Activate: return InputActionStep::Activate;
408+
case TokenType::ASL_OP_Deactivate: return InputActionStep::Deactivate;
409+
case TokenType::ASL_OP_Toggle: return InputActionStep::Toggle;
410+
case TokenType::ASL_OP_Reset: return InputActionStep::Reset;
411+
case TokenType::ASL_OP_Time: return InputActionStep::Time;
421412
// Arithmetic steps
422-
case arctic::TokenType::OP_Assign: return InputActionStep::Set;
423-
case arctic::TokenType::OP_Plus: return InputActionStep::Add;
424-
case arctic::TokenType::OP_Minus: return InputActionStep::Sub;
413+
case TokenType::OP_Assign: return InputActionStep::Set;
414+
case TokenType::OP_Plus: return InputActionStep::Add;
415+
case TokenType::OP_Minus: return InputActionStep::Sub;
425416
default: ICE_ASSERT_CORE(false); break;
426417
}
427418
return InputActionStep::Invalid;
@@ -431,13 +422,13 @@ namespace ice
431422
{
432423
switch (token.type)
433424
{
434-
case grammar::UCT_ModifierOpMax: return InputActionModifier::Max;
435-
case arctic::TokenType::OP_Div: return InputActionModifier::Div;
425+
case TokenType::ASL_OP_Max: return InputActionModifier::Max;
426+
case TokenType::OP_Div: return InputActionModifier::Div;
436427
// Not implemented yet
437-
case grammar::UCT_ModifierOpMin:
438-
case arctic::TokenType::OP_Mul:
439-
case arctic::TokenType::OP_Plus:
440-
case arctic::TokenType::OP_Minus:
428+
case TokenType::ASL_OP_Min:
429+
case TokenType::OP_Mul:
430+
case TokenType::OP_Plus:
431+
case TokenType::OP_Minus:
441432
default: ICE_ASSERT_CORE("Not Implemented!" && false); return InputActionModifier::Invalid;
442433
}
443434
}

0 commit comments

Comments
 (0)