Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Null values not supported #31

Open
tyrion opened this issue Sep 11, 2011 · 2 comments
Open

Null values not supported #31

tyrion opened this issue Sep 11, 2011 · 2 comments

Comments

@tyrion
Copy link
Contributor

tyrion commented Sep 11, 2011

It seems there is no support for null values.

tyrion@sword:~$ node run.js nulltest.yaml


---
  test: null


outputs:

{ test: 'null' }
@tyrion
Copy link
Contributor Author

tyrion commented Sep 11, 2011

Here's a patch:

diff --git a/lib/yaml.js b/lib/yaml.js
index 5c75b41..a682a76 100644
--- a/lib/yaml.js
+++ b/lib/yaml.js
@@ -39,6 +39,7 @@ var tokens = [
   ['space', /^ +/],
   ['true', /^\b(enabled|true|yes|on)\b/],
   ['false', /^\b(disabled|false|no|off)\b/],
+  ['null', /^\b(null|Null|NULL|~)\b/],
   ['string', /^"(.*?)"/],
   ['string', /^'(.*?)'/],
   ['timestamp', /^((\d{4})-(\d\d?)-(\d\d?)(?:(?:[ \t]+)(\d\d?):(\d\d)(?::(\d\d))?)?)/],
@@ -223,6 +224,7 @@ Parser.prototype.ignoreWhitespace = function() {
  * | int
  * | true
  * | false
+ * | null
  */

 Parser.prototype.parse = function() {
@@ -249,6 +251,8 @@ Parser.prototype.parse = function() {
       this.advanceValue(); return true
     case 'false':
       this.advanceValue(); return false
+    case 'null':
+      this.advanceValue(); return null
   }
 }

@tj
Copy link
Owner

tj commented Sep 12, 2011

can you make a pull-request? thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants