precisions on WML grammar

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
spir
Posts: 97
Joined: September 15th, 2009, 9:31 am
Contact:

precisions on WML grammar

Post by spir »

Hello,

I'm looking for some more information about WML grammar features, rather on morphological level (wiki page syntaxWML is nearly enough on syntax). This is partly for writing content, partly for grammar parsing and semantic validation (thread). Actually, I'm close to 100% sure on some of the items below, they are rather listed for the sake of completeness and to be really sure.
Then, I intend to update the said wiki page; or there may be a sticky post in this sub-forum. I would try to write things so that non-programmers actually have a chance to understand at once -- but someone must review (accuracy) & correct after me (english language, I mean).
  • support for unicode, in general
    If yes, what encoding allowed in source doc (eg utf8), what encoding used internally (class for unicode char/string in C++ code)?.
  • accurate morphology of identifiers
    Especially: are non-ascii letters allowed, or also other alphabets; or even any unicode character qualified as member of a scripting system? What about accents and other diacritics?
    <EDITt:> can an identifier start with underscore, can an identifier start with a digit?
  • set of valid "inline" characters
    Especially on the value side of an attribute definition.
  • set of valid characters for strings
    (what about unicode?)
  • set of valid characters for comments
    (what about unicode?)
  • accurate syntax for multiline text
    Is there more to know than "..." can hold an end-of-line (gotchas)?
  • accurate syntax for list value (",")


Some issues I wonder about:
  • text / type system
    I have the impression that, on WML side, all is text (string). Meaning that values are simply taken as are, e basta! If I'm right, WMl has no type system properly speaking, just 'data'. Not even string, for there is no real text processing (concatanation is no more than glueing data); data just happens to be stored as text (char array?), simply because it's read in that format.
    Am I right on this? If yes, I really approve, it is probably a Good Thing for a game scripting language.
  • $varname
    When/where is actually expression of variable value valid?
    Is there a difference of nature between "interface" variables (provided by the engine), custom ones (user-defined) and "event" variables (local inside [event])? Is there a difference in use?
  • $varname.attrname
    When/where is actually attribute referencing valid? Both for reading and writing. I'm really confused on this (always get errors because of that, then must find uneasy and heavy workarounds).
    Is there a difference for attribute access between interface/user/event variables?
  • delimiting & grouping, "..." & (...)
    If a value is simply text on WML side, then "..." is not needed in the general case, only when possible confusion occurs. Meaning that 'x=a' and 'x="a"' are basically synonyms. Am I right on this?
    The same for list values, (...) is generally not required; also multiple assignment. Correct?
    Is "..." an idiom for delimiting a single value (when whitespace inside), whatever its sense? Or only for values to be interpreted as string on C++ side?
    Also, for translation, is 't=_ foo' valid, or should I write 't=_ "foo"'? If the first expression is correct, what about 't=_ foo bar'? (additional question: what text value are not basically translatable?
    Is (...) *the* idiom for delimiting a list value (when more values come before or after, especially for macro argument)?
    Is this correct: 'loc1,loc2=(1,2),(3,4)', provided loc* is supposed to point to a WML array?
    <EDITt:> What about nested list in general, such as in 'positions=((a,(1,2)),(b,(3,4)))'
    Can (...) be used for delimiting a single value (when whitespace inside) like "..."? I mean especially, is '(a)' an individual data item, or a singleton? What about '(a b)'?
  • resources
    A more specific question: why, actually, are campaign resource files/dirs defined outside [campaign]. (I understand the need for a preprocessor flag "define=CAMPAIGN_FLAG"). Is it just a design choice, meaning we could actually have, for instance, a [resources] tag inside [campaingn], with an attribute for each kind of resources? (and a separate key for pics used to present the campaign in the campaign menu, before it's played).
  • FormulaAI & ${...} formula value
    Are there example uses of ${...} just for formula expression in the value of attribute?
    Are there example uses of FormulaAI properly speaking to write an AI?
    What about wiki pages for that?
  • [tag_name element_name]
    To end the list, a naughty question:
    Why is the name (id) of an individual element recorded like an attribute, while it's actually a variable name?
    Why not for instance:

    Code: Select all

    [unit Kalenz]
    	type=Elvish Lord
    	name=_ "Kalenz"
    	...
    [/unit]
    
    <or>
    
    [side elves]
    	name=_ "elves"
    	team=elf_allies
    	...
    [/side]
    
    Nice for identifying things at once, no?

Well, it's a fairly long list, indeed! Hope the answers will help others and write good games ;-)
Denis
life is strange

various stuff about BfW (rules, stats, alternatives) and WML (parser, semantic schema, evolution)
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: precisions on WML grammar

Post by silene »

spir wrote:support for unicode, in general
If yes, what encoding allowed in source doc (eg utf8), what encoding used internally (class for unicode char/string in C++ code)?.
UTF8 is the only supported encoding. (Obviously, any subset of it, e.g. ascii, works too.) The preprocessor itself does not care about encoding, as long as the char unit is the byte and recognized symbols (e.g., [,],{,},(,),",#,a-z) have the usual values.
spir wrote:accurate morphology of identifiers
Especially: are non-ascii letters allowed, or also other alphabets; or even any unicode character qualified as member of a scripting system? What about accents and other diacritics? <Edit:> can an identifier start with underscore, can an identifier start with a digit?
It is not clear what works and what doesn't work; your mileage may vary, depending on your operating system and locale support. What is clear is that the engine was designed with ascii only in mind, for identifiers. Underscores are fine, digits are too, even at beginning of identifiers.
spir wrote:set of valid "inline" characters
Especially on the value side of an attribute definition.
Any character is fine. Spaces are trimmed at both ends of a value if not quoted.
spir wrote:set of valid characters for strings (what about unicode?)
UTF8.
spir wrote:set of valid characters for comments (what about unicode?)
Anything, as long as the resulting sequence doesn't match one of the preprocessor commands (e.g. ifdef, textdomain).
spir wrote:accurate syntax for multiline text
Is there more to know than "..." can hold an end-of-line (gotchas)?
No particular syntax. Anything quoted is taken verbatim after preprocessor substitution.
spir wrote:accurate syntax for list value (",")
No uniform syntax. Each part of the engine is responsible for splitting the list into values the way it intends to.
spir wrote:text / type system
I have the impression that, on WML side, all is text (string). Meaning that values are simply taken as are, e basta! If I'm right, WMl has no type system properly speaking, just 'data'. Not even string, for there is no real text processing (concatanation is no more than glueing data); data just happens to be stored as text (char array?), simply because it's read in that format.
Am I right on this? If yes, I really approve, it is probably a Good Thing for a game scripting language.
Data is just stored as text, there is no type system. And no, it is not a good thing. Think about the horror of "equals", "numeric_equals", "boolean_equals" for instance; these keywords are precisely there because WML does not have a type system, not even an implicit one, contrarily to other scripting languages.
spir wrote:$varname
When/where is actually expression of variable value valid?
Is there a difference of nature between "interface" variables (provided by the engine), custom ones (user-defined) and "event" variables (local inside [event])? Is there a difference in use?
Again, each part of the engine is responsible for handling variable substitution, if it wants too. As a rule of thumb, variable substitution works in wml event filters and event actions only. There is no difference between engine/event variables and user variables.
spir wrote:$varname.attrname
When/where is actually attribute referencing valid? Both for reading and writing. I'm really confused on this (always get errors because of that, then must find uneasy and heavy workarounds).
Is there a difference for attribute access between interface/user/event variables?
Attributes and array indexing should work whenever variable substitution works. $ substitution is never valid for writing, whether there is an attribute or not, so I'm not sure what you mean. Again, no difference between engine and user variables.
spir wrote:delimiting & grouping, "..." & (...)
If a value is simply text on WML side, then "..." is not needed in the general case, only when possible confusion occurs. Meaning that 'x=a' and 'x="a"' are basically synonyms. Am I right on this?
You are right.
spir wrote:The same for list values, (...) is generally not required; also multiple assignment. Correct?
No. Parentheses are used for delimiting macro arguments. It doesn't have anything to do with list values.
spir wrote:Is "..." an idiom for delimiting a single value (when whitespace inside), whatever its sense? Or only for values to be interpreted as string on C++ side?
I would like it to be an idiom, but I don't think it is.
spir wrote:Also, for translation, is 't=_ foo' valid, or should I write 't=_ "foo"'? If the first expression is correct, what about 't=_ foo bar'? (additional question: what text value are not basically translatable?
_ foo is equivalent to "_ foo" (that is, the underscore becomes explicitly part of the string). Any text value containing a macro substitution is not translatable.
spir wrote:Is (...) *the* idiom for delimiting a list value (when more values come before or after, especially for macro argument)?
Again, parentheses are for delimiting macro arguments.
spir wrote:Is this correct: 'loc1,loc2=(1,2),(3,4)', provided loc* is supposed to point to a WML array?
No.
spir wrote:Can (...) be used for delimiting a single value (when whitespace inside) like "..."? I mean especially, is '(a)' an individual data item, or a singleton? What about '(a b)'?
No.
spir wrote:resources
A more specific question: why, actually, are campaign resource files/dirs defined outside [campaign]. (I understand the need for a preprocessor flag "define=CAMPAIGN_FLAG"). Is it just a design choice, meaning we could actually have, for instance, a [resources] tag inside [campaingn], with an attribute for each kind of resources? (and a separate key for pics used to present the campaign in the campaign menu, before it's played).
It is a design forced upon us by the legacy from a time where there was no concept of campaign. There is no technical reason, except for backward compatibility and inertia.
spir wrote:[tag_name element_name]
To end the list, a naughty question:
Why is the name (id) of an individual element recorded like an attribute, while it's actually a variable name?
Because there is no global notion of name. Each part of the engine is responsible for handling its own namespace, if any.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: precisions on WML grammar

Post by Anonymissimus »

silene wrote:
spir wrote:text / type system
I have the impression that, on WML side, all is text (string). Meaning that values are simply taken as are, e basta! If I'm right, WMl has no type system properly speaking, just 'data'. Not even string, for there is no real text processing (concatanation is no more than glueing data); data just happens to be stored as text (char array?), simply because it's read in that format.
Am I right on this? If yes, I really approve, it is probably a Good Thing for a game scripting language.
Data is just stored as text, there is no type system. And no, it is not a good thing. Think about the horror of "equals", "numeric_equals", "boolean_equals" for instance; these keywords are precisely there because WML does not have a type system, not even an implicit one, contrarily to other scripting languages.
Although a type system adds some complexity first, I'd like to see WML having one, too. It makes code easier to understand, interpret and stable in the end if you're forced to write
const unsigned int GotoX=10;
and such. I'm using type specific variable prefixes (i=integer, b=bool,...) but it is only meaningful for the wml programmer.
silene wrote:
spir wrote:delimiting & grouping, "..." & (...)
If a value is simply text on WML side, then "..." is not needed in the general case, only when possible confusion occurs. Meaning that 'x=a' and 'x="a"' are basically synonyms. Am I right on this?
You are right.
wmllint and wml interpretation seem to like x="a" more than x=a sometimes; what is more advisible ?

Also, wmllint seems to prefer yes-no over true-false/1-0 for boolean variables, although C++ doesn't know yes-no. (Don't wml variables become C++ variables on interpretation ?)
wiki wrote:When values are evaluated as boolean values they are checked to see if they are false or true.
These values are evaluated as false: no, false, off, 0, and 0.0
These values are evaluated as true: yes, true, on, 1, and 0.1 (and any other non-zero number)
So what is checked first and thus more advisable, ==yes/no ?
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: precisions on WML grammar

Post by silene »

Anonymissimus wrote:wmllint and wml interpretation seem to like x="a" more than x=a sometimes; what is more advisible ?
As far as I'm concerned, I use quotes when the value is a string, so as to have a specific syntactic coloring. But technically, there is nothing more advisable than the other.
Anonymissimus wrote:So what is checked first and thus more advisable, ==yes/no ?
The algorithm first tests for missingness or emptyness, then "yes", "no", "false", "off", "0", "0.0". (Notice that it never tests "on", "true", and so on.) So if you are only concerned about speed, don't put anything if you don't have to. And put "yes" and "no" if you have to put something.
User avatar
solsword
Code Contributor
Posts: 291
Joined: January 12th, 2009, 10:21 pm
Location: Santa Cruz, CA
Contact:

Re: precisions on WML grammar

Post by solsword »

Anonymissimus wrote: Although a type system adds some complexity first, I'd like to see WML having one, too. It makes code easier to understand, interpret and stable in the end if you're forced to write
const unsigned int GotoX=10;
and such. I'm using type specific variable prefixes (i=integer, b=bool,...) but it is only meaningful for the wml programmer.
Well... I'd much prefer an implicit type system. I know this is probably a minority perspective, and thus should be discounted, but I'll throw it out there: I absolutely hate type systems, because they require a horrendous amount of coding unrelated to any of my actual goals. As a fairly experienced programmer, I don't make type mistakes often, and I know how to debug them easily, so I generally find that the time wasted writing like 15 different versions of a function for different types (or wondering which of 5 API functions I should be using... or writing a new container subclass to hold my type of data... or....) is vastly greater than the time that I would save by catching type errors in the first place. Again, I know that this quite possibly isn't the case for the majority of WML programmers, but I'd also like to point out that a type system would be an additional barrier to entry for non-programmers picking up WML. Yes, it would almost certainly be helpful to them once they learned it, and avoid confusion, but it would also discourage some people from learning WML by making it more like a real programming language. I'd be fine with implicit types, though, or perhaps optionally explicit types (so that people who want to use them may).
Anonymissimus wrote:So what is checked first and thus more advisable, ==yes/no ?
The canonical advice, somewhere on the wiki, as I remember it, is that yes/no is preferable because it's easier for a non-programmer to understand. I generally tend to use yes/no most of the time, but I sometimes use true/false when it makes more sense in context. I'd avoid 1/0 as even more obscure. Also, since they're all going to go through a string phase, there's not going to be a measurable difference in speed. Seriously. EDIT: regarding silene's post: okay, I guess you'll save a few cycles by leaving it empty... but I'm pretty sure that since the WML is parsed only once, you're not going to have the interpretation cost inside any loops... so it's really not going to matter. Correct me if I'm wrong about this (maybe some creative use of runtime WML insertion?).
silene wrote:It is a design forced upon us by the legacy from a time where there was no concept of campaign. There is no technical reason, except for backward compatibility and inertia.
Well... I'd like to point out (same as in my earlier post somewhere, actually) that there are still plenty of add-ons that aren't campaigns which need to specify data directories and includes and such... and even for a campaign, there's no canonical list of what resource directories are needed. Sure you could make all of the proposed [campaign] subtags optional, but what if someone wanted to use more directories than however many tags there were? Or wanted to use a non-standard directory, and was forced to mis-use one of the proposed tags. Also, at this point, everything except [binary_path] is handled by the preprocessor, which doesn't know how to read WML, so making things tags in the [campaign] block would require extending the preprocessor to parse those.

On this point: I really like the way that it works now. I realize that it's perhaps somewhat difficult to understand for new players, who assume that it just works by black magic and blindly copy from other campaigns, often trying to change things around but failing... but I think that with a good explanation, its a very simple system. That's precisely because there is no black magic to deal with (okay, there's the bit about _main.cfg, and there's stuff involving the [binary_path] tag, which is slightly black-magic-ish, but there's no WML tag name to misspell, or magical set of standard include directories, etc.). You get to tell the system exactly which files you want it to paste in, and in which order. It pastes things together, and then processes the resulting lump. If you want a file or directory, you can add it. This is also quite useful for debugging: let's say that you've got some hard-to-track WML error: you can comment out your include of your macro directory, and then add includes for each individual macro file. Then you can go around commenting these includes one by one until your error changes, and you've likely found your problem. With a pre-defined [resources] tag, this likely wouldn't be possible. Now I'm starting to think of more clever things to do. For example, I suspect that you could use #ifdef EASY and such statements to bracket unit file includes, thereby making units have different properties on different difficulty levels, which would be an interesting mechanic...
The Knights of the Silver Spire campaign.

http://www.cs.hmc.edu/~pmawhorter - my website.

Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: precisions on WML grammar

Post by silene »

solsword wrote:so making things tags in the [campaign] block would require extending the preprocessor to parse those.
No. (And just so that there is no misunderstanding, I wrote the preprocessor.)

Think about it, the current campaign tag already contains preprocessor-specific data:

Code: Select all

[campaign]
    id=An_Orcish_Incursion
    difficulties="EASY,NORMAL,HARD"
    define="CAMPAIGN_AN_ORCISH_INCURSION"
So why do you think that the preprocessor would have to be changed if there was a "resources" tag in addition to the "define" and "difficulties" attributes?
(Note that I don't necessarily agree with using such a tag. This is just to show that it doesn't make a bit of difference from the C++ point of view.)
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: precisions on WML grammar

Post by Anonymissimus »

silene wrote:
Anonymissimus wrote:So what is checked first and thus more advisable, ==yes/no ?
The algorithm first tests for missingness or emptyness, then "yes", "no", "false", "off", "0", "0.0". (Notice that it never tests "on", "true", and so on.) So if you are only concerned about speed, don't put anything if you don't have to. And put "yes" and "no" if you have to put something.
I have taken from C++ this habit to initialize always everything. Querying suddenly [if][varaible]name=...not_equals=yes without mentioning the variable previously makes the code less redable, while when initializing the variable with yes or no there's no need for the "not" in the key. I've recently read about a case when it's actually important to initialize a variable even im wml, but I can't remember the context, unfortunately.
solsword wrote:I know this is probably a minority perspective, and thus should be discounted, but I'll throw it out there: I absolutely hate type systems, because they require a horrendous amount of coding unrelated to any of my actual goals. As a fairly experienced programmer, I don't make type mistakes often, and I know how to debug them easily, so I generally find that the time wasted writing like 15 different versions of a function for different types (or wondering which of 5 API functions I should be using... or writing a new container subclass to hold my type of data... or....) is vastly greater than the time that I would save by catching type errors in the first place.
I don't know anything about your programming experience, but in C++ at least, I'd try to use templates here (a pretty cool solution for this problem). Methods get a placeholder template variable type as arguments then, which is filled with a concrete variable type while compiling, according to the place where the method is called - so no need for different methods doing the same for different variable types.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
solsword
Code Contributor
Posts: 291
Joined: January 12th, 2009, 10:21 pm
Location: Santa Cruz, CA
Contact:

Re: precisions on WML grammar

Post by solsword »

@silene: wow. I can't imagine how I didn't think about that. Sorry. Just goes to show why you should always listen to a dev on these subjects!

@Anonymissimus: templates do make types somewhat less painful (again, just my perspective here), but they're no panacea (and have some of their own ugly issues about typesafety, if you want to be pedantic about your static typing... which I don't). When I mentioned multiple functions I was thinking more about C APIs like OpenGL or BLAS (where you don't have templates). I'll stress this: this is really just my opinion, and it may well be best to ignore it and go with something else. I'm just strongly opinionated about this and wanted to have my opinion heard, even though I'll understand if it's ignored.
The Knights of the Silver Spire campaign.

http://www.cs.hmc.edu/~pmawhorter - my website.

Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
spir
Posts: 97
Joined: September 15th, 2009, 9:31 am
Contact:

Re: precisions on WML grammar

Post by spir »

@ silene:
Thank you very much for this complete and accurate answer. I will study the question as soon as I have time (I first need to go on the topic pointed in initial post), then try to write a wiki page draft.

@ all:
Upon the question of type system, well, I guess that relevant discussion and reflexion must be based on a clear statement about target audience and use field for the language -- which is indeed the case for WML. As soon as we forget that, we enter general debates which, while interesting (and passionned, and endless ;-)), can be avoided in our case.
I have some ideas, sure, mainly because I've been interested in the topic of PLs for newcomers for a long time. IMO, we can state prerequisite requirements on people:
  • Basic knowledge and competence in the field of western techno-science (a huge sum of prerequisites, mainly implicit by us).
  • Strong and durable motivation to learn and use the language.
  • Over the average set of skills I sum up as "clarity" (namely: consistency, simplicity, acurracy on one side, intuition and creativity on the other).
Provided "candidate programmers" fulfills these requirements, they are IMO able to start the adventure; if only the language and all its environment are well thought out. This means, I guess, designing every language feature (including its own meta language such as words like "type" or "tag") with the user (programmer) point of view in mind constantly, always giving it higher precedence over whatever other standpoint.

In the case of type systems, this translates to designing and naming types at the conceptual level: what they mean, what they are used for. Eg such terms as float, boolean, double (and even int) and matching concept have nothing to do in WML.
Even "integer": what does it mean for the programmer? what does s/he use it for? Nothing -- "integer" is meaningless, except for very field-specific use cases, mainly maths themselves. On the other hand, all programs need & use indexes (ordinals) and counts (cardinals). Sure, both are (non-negative) integers and in fact have exactly the same valid range (when index base is 0). Note that not only they are meaningful as opposed to integer, but their meanings/uses are strictly distinct, even if the underlying "type" and value field is identical. I find this a striking example of switch of point of view.

Concretely, whether there is in a language such as WML a real type system with associated sets of operations, or on the contrary a pure convention is a secondary choice that will mainly influence entry barrier and later ease if use. Contradictory requirements, I guess, in this case :( . But probably users expect something similar to types, precisely because different kinds of values really have different meanings; and also to be able to straightforwardly express basic operations such as arithmetic ones, that they already know and expect to find in programming. I guess not providing this in WML is a flaw especially for beginners, (1) for it removes meaningful differences (an index is not a name), (2) for this leads to abstracting operation expression into a purely artificial and contorsed idiom.

Actually, there are at least 3 levels of type design:
  • optional convention (more or less the case in WML)
  • required convention
  • actual type system (on the WML side)
Note that on the side of C++ all three cases may be, or not, implemented as WML_*_Value classes; or use C types to represent them; or whatever solution is handy and KISSy. It's important to have the distinction clear in mind (python, for instance, as well as its literature, often messes up the language itself and its implementation design).
Also, all 3 systems allow operations: provided 2 values can be interpreted as valid numbers, '+' can be performed, meaning a temporary conversion into whatever representation in C for the time of the operation, and back to WML-side representation.

In the case of a required convention (which I would favor), there should be at parsing or interpretation time (*) a value checking system that may eg output such feedback:
"Expected logical value ('yes' or 'no') for attribute 'canrecuit'. Found 'yo!' instead."
I think any user we wish to be able to contribute UMC, esp. if meeting the above listed requirements, would not only understand and cope with this, but welcome and even enjoy such requirements and messages: it meets, I guess, both their expectations and their needs.

my 3 cents

(*) An actual semantic validation phase would be best, indeed!
Denis
life is strange

various stuff about BfW (rules, stats, alternatives) and WML (parser, semantic schema, evolution)
spir
Posts: 97
Joined: September 15th, 2009, 9:31 am
Contact:

Re: precisions on WML grammar

Post by spir »

Hello,

Here is an attempt at defining a formal grammar for WML, at both mophology and syntax levels. Well, I wrote: "an attempt" ;-) (mainly because I have no source specification, and I won't test it -- yet).
The grammar itself uses a custom PEG-like language, namely: pijnu, I guess you will understand at once. Later I may test it using pijnu's (python) parser generator (it does not yet cope with unicode charsets).

This formal specification would be, I guess, a good base to improve the WML syntax wiki page. It may deal as reference for anything, actually.
Note: I looked for such a thing in the source, but could not find it, not even in serialization/parser.cpp.
grammar:
I need comments, critics, improvements.
Denis
life is strange

various stuff about BfW (rules, stats, alternatives) and WML (parser, semantic schema, evolution)
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: precisions on WML grammar

Post by silene »

spir wrote:

Code: Select all

	TRANSLATION		: " _"
The translation underscore also works when there is no space before it.
spir wrote:

Code: Select all

	FORMULA_OPEN	: '{'
	FORMULA_CLOSE	: '}'
Braces are preprocessor symbols. Formulas use parentheses.
spir wrote:

Code: Select all

	value			: formula_eval / variable_eval / translation_text / text / base_value
This is hardly complete, as evaluations can be part of strings and strings themselves can be concatened. In fact, concatenation happens before evaluation, so adding spurious splits is a good way to obfuscate scenarios. Quizz: what is the value of $(2*2+1) in WML?
User avatar
Gambit
Loose Screw
Posts: 3266
Joined: August 13th, 2008, 3:00 pm
Location: Dynamica
Contact:

Re: precisions on WML grammar

Post by Gambit »

Lol I'm guessing from your quiz WML doesn't follow standard order of operations? It's either 5 or 6.
I'm going with 6 because 5 is the real world answer and WINR. :lol2:


Also I know Silene already said that # will work for comments as long as it doesn't match some operation like #ifdef or #define but wouldn't it be safer just to tell newbies in the wiki to use ## for comments?
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: precisions on WML grammar

Post by silene »

Gambit wrote:Lol I'm guessing from your quiz WML doesn't follow standard order of operations? It's either 5 or 6.
I'm going with 6 because 5 is the real world answer and WINR.
You lose, 6 is not the answer. (And 5 is not either, obviously.)
spir
Posts: 97
Joined: September 15th, 2009, 9:31 am
Contact:

Re: precisions on WML grammar

Post by spir »

Gambit wrote:Lol I'm guessing from your quiz WML doesn't follow standard order of operations? It's either 5 or 6.
I'm going with 6 because 5 is the real world answer and WINR. :lol2:
Well, if it didn't apply precedence, the result of evaluation would be 5 anyway ;-)
For me, strictly speaking, the value of $(whatever) in WML is '$(whatever)' (the piece of text). But its just me...
Denis
life is strange

various stuff about BfW (rules, stats, alternatives) and WML (parser, semantic schema, evolution)
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: precisions on WML grammar

Post by silene »

spir wrote:For me, strictly speaking, the value of $(whatever) in WML is '$(whatever)' (the piece of text). But its just me...
This is not even true (and this is why the quizz has a bit of interest). So, just to make things clearer: you can give either the correct piece of text ("$(2*2+1)" is not) or the integer value after evaluation.
Post Reply