What does a single exclamation mark do in YAML?

I’m working with the YamlDotNet library and I’m getting this error when loading a YAML file:

While parsing a tag, did not find expected tag URI.

The YAML file is supposed to be well-formed because it comes right from RoR. The error seems to be triggered by this code:

formats:
  default: ! '%d-%m-%Y'
  long: ! '%d %B, %Y'
  short: ! '%d %b'

I’m not an expert, but I see from the YAML spec that you can use an exclamation mark to indicate a custom object/type, and two exclamation marks to indicate an explicit built-in type.

obj1: !custom # whatever
obj2: !!str "My string"

However I haven’t been able to find any reference to an exclamation mark used as above. What does that mean, and why the YAML library I use doesn’t seem able to parse it? Note that if I remove those exclamation marks, the file is parsed fine.

What does the ! (exclamation mark) mean before selector in jQuery

I know already that the ! is used generally to express negation like no, not, and null in JavaScript. But what does the exclamation mark mean before a selector in jQuery? if(!$(‘selector’).hasClass(‘s

What does an exclamation mark in Lua do?

Question is in the title, really. I saw someone use this earlier and I didn’t know what the ! was used for. local lowestIndex = 0; local lowestValue = false; for k, v in ipairs(playerElement) do if !l

exclamation mark before a NSString

Please do tell me what does an exclamation mark mean before a NSString NSString *theString; if (!theString); cheers;

What does the exclamation mark mean in a Haskell declaration?

I came across the following definition as I try to learn Haskell using a real project to drive it. I don’t understand what the exclamation mark in front of each argument means and my books didn’t seem

What does the exclamation mark mean in a Haskell declaration?

I came across the following definition as I try to learn Haskell using a real project to drive it. I don’t understand what the exclamation mark in front of each argument means and my books didn’t seem

What does an exclamation mark before a function really mean in PHP

Just as in the title, what does an exclamation mark before a function really mean in PHP? For example is the following statement: if (!stripos($haystack, $needle)) {} the same as this: if (stripos($

what does an exclamation mark follow with variable mean in ruby on rails?

i was reading tutorials for rails 3 with mongodb and i see something like this # Note this: ids are of class ObjectId. key :user_id, ObjectId timestamps! what does the exclamation mark mean??? Thank

What is the reason for a red exclamation mark next to my project in Eclipse?

I have a red exclamation mark over my projectname in Eclipse. Does anyone know what this means and what I should I do about it? How do I determine where or what the problem is? Any help is appreciat

What does the red exclamation point icon in Eclipse mean?

What does the red exclamation point icon in Eclipse mean? There are lots of different search results on the Internet about red exclamation point icons and red exclamation mark decorators and red

what is the Exclamation mark mean in eclipse ? android project

I just do some update to the ADT plugin, and then an Exclamation mark appear next to my project. I check the build path and found a problem with android dependencies: what should I do ? this another

Answers

That “!” is the “non-specific tag”.

YAML specification 1.2 stays (also 1.1):

By explicitly specifying a “!” non-specific tag property, the node would then be resolved to a “vanilla” sequence, mapping, or string, according to its kind.

Take a look here to the tag “grammar”:

none    : Unspecified tag (automatically resolved by application).
'!'     : Non-specific tag (by default, "!!map"/"!!seq"/"!!str").
'!foo'  : Primary (by convention, means a local "!foo" tag).
'!!foo' : Secondary (by convention, means "tag:yaml.org,2002:foo").
'!h!foo': Requires "%TAG !h! <prefix>" (and then means "<prefix>foo").
'!<foo>': Verbatim tag (always means "foo").

Why is YamlDotNet throwing a error? I can’t be 100% sure, but I think you found a bug.

YamlDotNet is a port of LibYAML, so it’s easy to compare sources.

Line 2635 of scanner.c (LibYAML):

/* Check if the tag is non-empty. */
if (!length) {

Line 2146 of Scanner.cs (YamlDotNet ):

// Check if the tag is non-empty.
if (tag.Length == 0)

I know, both looks very similar, but at this point length is 1 and tag.Length is 0. Original C code takes care of the initial “!” (whole length) but C# doesn’t do it (just the tag “name” length).

Fill an issue to the project.