esilkensen / yaml Goto Github PK
View Code? Open in Web Editor NEWA YAML library for Racket.
License: MIT License
A YAML library for Racket.
License: MIT License
Quick question.
I'm interested in customizing the data-structures produced by the parser. For example, I want to create an ordered mapping object instead of using #hash()
structures or perhaps use immutable hashes.
Would you suggest I use the yaml/events
module? If so, I could try that out and maybe document it.
Thanks for your work.
The following yaml causes an error.
check: []
I get when loading this yaml:
make-constructor: broke its own contract
promised: (or/c yaml? void?)
produced: '#hash(("checks" . ()))
in: the range of
the range of
(->*
()
(input-port?)
(values
(-> boolean?)
(-> (or/c yaml? void?))
(-> (or/c yaml? #f))))
contract from:
<pkgs>/yaml/yaml/constructor.rkt
blaming: <pkgs>/yaml/yaml/constructor.rkt
(assuming the contract is correct)
at: <pkgs>/yaml/yaml/constructor.rkt:21.3
Yaml document contains scalars with unicode characters are written using escaped characters. Such files cannot be read back.
Steps to reproduce:
Test file: test.yaml.txt
> (file->yaml "test.yaml")
'#hash(("key" . "Å üñíçòðę vǎlûe"))
> (yaml->string (file->yaml "test.yaml"))
"{key: \"\\xC5 \\xFC\\xF1\\xED\\xE7\\xF2\\xF0\\u119 v\\u1CEl\\xFBe\"}\n"
> (string->yaml (yaml->string (file->yaml "test.yaml")))
; string:0:38: while scanning a double-quoted scalar;
; expected escape sequence, but found
; [,bt for context]
Problem can be solved with the attached patch:
allow-unicode.patch.txt
> (file->yaml "test.yaml")
'#hash(("key" . "Å üñíçòðę vǎlûe"))
> (yaml->string (file->yaml "test.yaml") #:allow-unicode? #t)
"{key: Å üñíçòðę vǎlûe}\n"
> (string->yaml (yaml->string (file->yaml "test.yaml") #:allow-unicode? #t))
'#hash(("key" . "Å üñíçòðę vǎlûe"))
Rename test files from the YAML spec, e.g., "ex2-1" to "spec02-01.yaml".
Expand the test suite to include other examples from the spec and the PyYAML repository: See http://svn.pyyaml.org/pyyaml/trunk/tests/data/ and http://yaml.org/spec/
What happens when there are multiple yaml-struct
definitions with the same name (and what if they are in different scopes, modules, etc.)?
-> (write-yaml '(1 2 3) #:style 'flow)
; make-representer: contract violation
; expected: (or/c (quote block) (quote flow) (quote best) #f)
; given: #t
; in: the #:style argument of
; (->*
; ((-> node? void?))
; (#:scalar-style
; (or/c #\" #\' #\| #\> 'plain #f)
; #:style
; (or/c 'block 'flow 'best #f))
; (-> yaml? void?))
The following YAML input is not constructed correctly:
canonical: 2001-12-15T02:59:43.1Z
iso8601: 2001-12-14t21:59:43.10-05:00
spaced: 2001-12-14 21:59:43.10 -5
date: 2002-12-14
The "iso8601" and "spaced" dates return the wrong hour value.
I see that yaml requires cover-coveralls, and it looks to me like this is used only in the travis script. This is a bit of a bummer if I want to include yaml in another project... is the coverage testing a significant component of the CI testing?
Hmm... well, I suppose you could argue either way.
I think for an object that has many attributes, the output will be easier for humans to read if the keys are ordered. This may also apply to sets.
Consider moving away from Travis and using GitHub Actions instead.
The Travis build runs Coveralls but fails to run the tests and reports only 15% coverage. Probably a yaml/yaml directory issue.
Refactor scanner.rkt, parser.rkt, etc. to use Racket classes or structs instead of closures / constructors that return values.
Evaulate this program
#lang racket
(require yaml)
(string->yaml ": {fall: [], winter: [], spring: []}")
see this error:
format: format string requires 0 arguments, given 1; arguments were: "expected , but found" "':'"
It certainly looks like the part of the code that's supposed to signal this error message has a bad format string.
Entering the examples from the documentation breaks the make-serializer
contract:
> (write-yaml
'(#hash(("name" . "Mark McGwire")
("hr" . 65)
("avg" . 0.278))
#hash(("name" . "Sammy Sosa")
("hr" . 63)
("avg" . 0.288))))
; make-serializer: broke its own contract;
; expected 1 value, returned 3 values
; in: the range of
; (->*
; ()
; (output-port?
; #:allow-unicode
; boolean?
; #:canonical
; boolean?
; #:explicit-end
; boolean?
; #:explicit-start
; boolean?
; #:indent
; (or/c exact-positive-integer? #f)
; #:line-break
; (or/c "\n" "\r" "\r\n" #f)
; #:tags
; (or/c (hash/c string? string?) #f)
; #:version
; (or/c
; (cons/c exact-integer? exact-integer?)
; #f)
; #:width
; (or/c exact-positive-integer? #f))
; (-> node? void?))
; contract from:
; /Users/Erik/Documents/Code/yaml/yaml/serializer.rkt
; blaming: /Users/Erik/Documents/Code/yaml/yaml/serializer.rkt
; (assuming the contract is correct)
; at: /Users/Erik/Documents/Code/yaml/yaml/serializer.rkt:15.3
The "~" character in YAML needs to be escaped in Racket printf patterns.
Code containing tab characters generate error messages containing tabs, which can be difficult to decipher:
#lang racket
(require yaml)
(string->yaml "name: Oracle
\tid: oracle
description: Oracle.
" )
This results in the error:
string:1:0: while scanning for the next token;
found character that cannot start any token
... which is a bit of a challenge to read.
As it is right now, this library seems to have no license (unless I've missed it). I'm not sure if this is intentional --- if so, I apologize for bothering you.
If not, GitHub's Choose a License site is a pretty good starting point for picking a license.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.