Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
794fa8a2
Commit
794fa8a2
authored
Mar 24, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
non-optional keyword parameters
parent
89de0488
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
data/magic.mse-game/game
data/magic.mse-game/game
+4
-0
src/data/keyword.cpp
src/data/keyword.cpp
+12
-4
src/data/keyword.hpp
src/data/keyword.hpp
+4
-1
No files found.
data/magic.mse-game/game
View file @
794fa8a2
...
...
@@ -941,7 +941,11 @@ keyword parameter type:
match: [^(.,\n]+
keyword parameter type:
name: prefix
description: Prefix for things like "<something>walk"
placeholder: land
optional: false
match: [A-Z][a-z]*
example: Forest
############################# All Magic keywords
# By JrEye and Neko_Asakami
...
...
src/data/keyword.cpp
View file @
794fa8a2
...
...
@@ -18,11 +18,18 @@ DECLARE_TYPEOF_COLLECTION(const Keyword*);
// ----------------------------------------------------------------------------- : Reflection
KeywordParam
::
KeywordParam
()
:
optional
(
true
)
{}
IMPLEMENT_REFLECTION
(
KeywordParam
)
{
REFLECT
(
name
);
REFLECT
(
description
);
REFLECT
(
placeholder
);
REFLECT
(
optional
);
REFLECT
(
match
);
REFLECT
(
script
);
REFLECT
(
example
);
}
IMPLEMENT_REFLECTION
(
KeywordMode
)
{
REFLECT
(
name
);
...
...
@@ -129,7 +136,7 @@ void Keyword::prepare(const vector<KeywordParamP>& param_types, bool force) {
}
parameters
.
push_back
(
p
);
// modify regex
regex
+=
_
(
")("
)
+
make_non_capturing
(
p
->
match
)
+
_
(
")
?
("
);
regex
+=
_
(
")("
)
+
make_non_capturing
(
p
->
match
)
+
_
(
")
"
)
+
(
p
->
optional
?
_
(
"?"
)
:
_
(
""
))
+
_
(
"
("
);
i
=
skip_tag
(
match
,
end
);
}
else
{
regex
+=
regex_escape
(
c
);
...
...
@@ -365,17 +372,18 @@ String KeywordDatabase::expand(const String& text,
String
part
=
s
.
substr
(
start
,
part_end
-
start
);
if
((
j
%
2
)
==
0
)
{
// parameter
KeywordParam
&
kwp
=
*
kw
->
parameters
[
j
/
2
-
1
];
String
param
=
untagged
.
substr
(
start_u
,
len_u
);
// untagged version
if
(
param
.
empty
())
{
// placeholder
param
=
_
(
"<atom-kwpph>"
)
+
kw
->
parameters
[
j
/
2
-
1
]
->
name
+
_
(
"</atom-kwpph>"
);
param
=
_
(
"<atom-kwpph>"
)
+
(
kwp
.
placeholder
.
empty
()
?
kwp
.
name
:
kwp
.
placeholder
)
+
_
(
"</atom-kwpph>"
);
part
=
part
+
param
;
// keep tags
}
else
if
(
kw
->
parameters
[
j
/
2
-
1
]
->
script
)
{
// apply parameter script
ctx
.
setVariable
(
_
(
"input"
),
to_script
(
part
));
part
=
kw
->
parameters
[
j
/
2
-
1
]
->
script
.
invoke
(
ctx
)
->
toString
();
part
=
kw
p
.
script
.
invoke
(
ctx
)
->
toString
();
ctx
.
setVariable
(
_
(
"input"
),
to_script
(
part
));
param
=
kw
->
parameters
[
j
/
2
-
1
]
->
script
.
invoke
(
ctx
)
->
toString
();
param
=
kw
p
.
script
.
invoke
(
ctx
)
->
toString
();
}
ctx
.
setVariable
(
String
(
_
(
"param"
))
<<
(
int
)(
j
/
2
),
to_script
(
param
));
}
...
...
src/data/keyword.hpp
View file @
794fa8a2
...
...
@@ -23,8 +23,11 @@ class KeywordTrie;
/// Parameter type of keywords
class
KeywordParam
{
public:
KeywordParam
();
String
name
;
///< Name of the parameter type
String
description
;
///< Description of the type
String
description
;
///< Description of the parameter type
String
placeholder
;
///< Placholder for <atom-kwpph>, name is used if this is empty
bool
optional
;
///< Can this parameter be left out (a placeholder is then used)
String
match
;
///< Regular expression to match
OptionalScript
script
;
///< Transformation of the value for showing in the reminder text
String
example
;
///< Example for preview dialog
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment