1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-03 07:24:58 +03:00
inform7/inbuild/supervisor-module/Chapter 6/Virtual Machine Grammar.w
Graham Nelson 1268a0f40e Colonised
2020-04-14 17:56:54 +01:00

35 lines
1,018 B
OpenEdge ABL

[VMGrammar::] Virtual Machine Grammar.
Grammar for parsing natural language descriptions of a virtual machine.
@ This nonterminal corresponds to the Inbuild version number syntax in the
arch module: for example, it matches |2.7.6| or |3/990505|.
=
<version-number> internal 1 {
TEMPORARY_TEXT(vtext);
WRITE_TO(vtext, "%W", W);
semantic_version_number V = VersionNumbers::from_text(vtext);
int result = FALSE;
if (VersionNumbers::is_null(V) == FALSE) {
result = TRUE;
semantic_version_number_holder *H = CREATE(semantic_version_number_holder);
H->version = V;
*XP = (void *) H;
}
DISCARD_TEXT(vtext);
return result;
}
@ The following nonterminal matches any valid description of a virtual machine,
with result |TRUE| if the current target VM matches that description and
|FALSE| if not.
=
<virtual-machine> internal {
TEMPORARY_TEXT(vtext);
WRITE_TO(vtext, "%W", W);
compatibility_specification *C = Compatibility::from_text(vtext);
if (C) { *XP = C; return TRUE; }
*XP = NULL; return FALSE;
}