The YAML type repository you link to several times is not valid for YAML 1.2 and is also only an optional addendum to YAML 1.1. In YAML 1.2, there are several recommended schemas, none of which accepts no
as boolean value. 0xC
is only an integer when using the Core Schema; not when using the JSON Schema. _
is not allowed in numbers.
Indeed, while I can easily write a conforming JSON parser over a weekend (which I've actually done for fun), even just trying to fully grasp the YAML 1.2 specification would take me more time than I can spare, much less actually implementing it which I doubt would be fun at all.
PS: And then there's the thing about parsers implemented in C being prone to buffer overflow exploits where complexity of the language isn't beneficial either.
Hah :)
But what about this...? 3:) ;D
> Why does YAML forbid tabs?
> Tabs have been outlawed since they are treated differently by different editors and tools. And since indentation is so critical to proper interpretation of YAML, this issue is just too tricky to even attempt. Indeed Guido van Rossum of Python has acknowledged that allowing TABs in Python source is a headache for many people and that were he to design Python again, he would forbid them.
You're probably looking for something like YAML.
Your lists could be YAML objects.
>require 'yaml'
And then generate your lists as YAML objects. You can then cycle through for comparison, or spawn off several comparisons at once. The objects don't have to be written to storage, they can just sit in memory (iirc).
Just to explain your specific issue a little more, the '{' character, unquoted, as the first character, is treated as an object/map in YAML. Not using a double quote as the first character of a string is an allowed short-cut in most cases, but you can ALWAYS use the quotes to make sure your string value is parsed correctly.
I don't believe it, for a simple reason: Python's AST is wickedly complex. Lisp's is as simple as this:
Type ast = Number of float | Char of char | String of string | Symbol of string | List of ast list
That is what Lisp's power come from. No matter how nice or complex the reader is, the AST will stay simple and uniform.
Besides, if you're honest about it, Lists aren't Lisp's true AST. See, other languages go straight from characters to a complex AST, which differentiate function calls from if
statements and such. Lisp is a little different: once you've gone through the nested list stage, and resolved all macros, you handle special forms. And those certainly distinguish straight function calls from the likes of cond
. Even if this "true AST" is still simpler than Python's, you never get to manipulate it —just like Python's.
C and M4 macros are incredibly dangerous because they act on a structureless stream of characters. Ocaml's Camlp4's pre-processor avoid this trap by acting directly on the deep AST, but this is unwieldy. Lisp takes a nice middle ground by devising an intermediate not-quite-AST that shows just enough structure to be quite safe, yet be nimble.
This agility will never be lost just because you replace some parentheses by indentation. Check out YAML: no matter how complex the concrete syntax, the APIs have you manipulate the simpler tree structure behind it.
I had a discussion over at HN about YAML. Well I was commenting on how YAML would be a better alternative than JSON.
A user counter with YAML is complex and too many rules and that TOML would be better.
But the point being that YAML have tons rules, it looks very simple though.
https://github.com/toml-lang/toml
Here's the spec for YAML:
http://www.yaml.org/spec/1.2/spec.html
This could be the reason for: "Because YAML is too complex"
There is a YAML Serialization Library that will be helpful. Read the YAML file into a data structure that you can bind to the TreeView
I only comment one line at a time. I checked the automoderator documentation, and briefly checked the YAML documentation, and I don't see a multiline comment option.
Check out some other mark up reference documents, yaml springs to mind as it looks similar ish to what you've written
http://www.yaml.org/spec/1.2/spec.html
If you could write a BNF or similar as well that would also help.
Hmm... I have not run into those problems, but I used Sublime Text 3 as a text editor - I'll have to check at home this evening, if you really can't edit with the standard tools. That's really interesting, thanks for the PSA!
In general though, the files are using the YAML serialization language. That means you have to watch your intendations - they're not simple ini files. If anyone's interested, you can find more about it here:
I think YAML (http://www.yaml.org) does a good job of providing both computer and human readable data files, however it doesn't allow for that easy row-like comparison that is certainly useful...if only there was a decent YAML > table viewer.
It seems like this could be built as an extension of YAML (http://www.yaml.org/) with little effort. I don't even know if people do or ever did use YAML, but it's a very nice markup language and appears to be well-supported.
It's only officially been a superset since 2009
> The primary objective of this revision is to bring YAML into compliance with JSON as an official subset.
FUD? I literally linked to the part of the YAML 1.1 spec that says that Y and N should be implicitly coerced to boolean. If you need further proof, here's the yaml.org official YAML 1.1 quick reference, which also has Y and N in its list of bool examples.
On further investigation, you're right that PyYaml claims to be a YAML 1.1 parser; I have no explanation for why PyYaml doesn't conform to the spec in this regard.
Yaml parsers should reject files with tabs. If you see some tabs and your tabstop is set to 4 then you just run %:s/\t/ /g
in vim and you're done. Or sed -i 's/\t/ /g' <filename>
from the command line. Or whichever tool. I'm sure it's not hard to search and replace in your favourite IDE.
For example if you're loading a yaml file in Python you should get the following exception:
ScannerError: while scanning for the next token found character '\t' that cannot start any token in "abc.yml", line 7, column 1
The first and second are equivalent as far as the semantics of the YAML parser is concerned. (See http://www.yaml.org/spec/1.2/spec.html#id2772075). The greater-than symbol indicates that the value for the key "service" will comprise the subsequent indented lines (with newlines and trailing whitespace expunged).
> I'm not sure if YAML is used in other programming languages
YAML is definitely not specific to Ruby. The one-line description on the YAML website is literally "YAML is a human friendly data serialization standard for all programming languages" followed by links to implementations for a dozen languages.
YAML does have a lot of really nice things, but I'll give a rough basics:
It can be used for simple fields:
POV: Bob When: 2014-02-11 12:02:02
It can have short lists for a key (such as longitude/latitude since I'm going to map chapters on a map someday). This can either be a [] or a newline with - lines.
Where: [41.9831, 91.6686] Characters: - Bob - Gary
You can have nested keys too
WordCount: Maximum: 2500 Minimum: 1500
Overall, that is usually what I use in the headers.