Commit Graph

144 Commits

Author SHA1 Message Date
Felix Krause 34cbe61479 Got rid of lots of compiler warnings 2016-08-17 22:50:37 +02:00
Felix Krause 01b34290b7 Parser refactoring
* refactored parser to not use first class iterators
   (not available for JS backend)
 * Current state misses flow style handling and fails tests
2016-08-15 21:30:49 +02:00
Felix Krause 7cad7b5478 Fixed and properly implemented variant objects 2016-06-08 19:15:50 +02:00
Felix Krause 273093e390 improved setTagUri
* renamed setTagUriForType to setTagUri
 * generated TagId is now const (can be used in case etc)
 * Uses compile-time counter independent from tag library
2016-04-21 18:58:53 +02:00
Felix Krause 4ca4b2c87e Support nil strings and seqs 2016-04-04 21:21:24 +02:00
Felix Krause 58b9b92895 Support int, uint and float types. 2016-04-04 20:44:16 +02:00
Felix Krause 6ad7e33bb5 Reduced dead code and compiler warnings 2016-04-03 11:45:48 +02:00
Felix Krause f2c83cc170 Support array types. Updated documentation 2016-04-03 11:29:49 +02:00
Felix Krause a267f73e0a Serialization: support sets 2016-04-02 18:29:26 +02:00
Felix Krause cde346b85c Switched to indentation of 2 spaces 2016-04-02 17:48:22 +02:00
Felix Krause 5ec086081c Implemented serialization of OrderedMap 2016-03-25 22:22:42 +01:00
Felix Krause 42ddfbe5c5 Fixes #13.
* Separated into representObject and in representChild and
   representObject. Makes it possible for multiple types to
   use the same representObject proc.
2016-03-25 21:27:41 +01:00
Felix Krause 28ccdcc5a6 Handle block scalars line-per-line. Fixes #10 2016-03-25 18:17:37 +01:00
Felix Krause 4d4e3c94e1 Added fplDocument, fixes #11
* Do not use -1 for unknown indentation, because the document level is -1.
 * Use const UnknownIndentation in code instead of magic number
 * Added fplDocument level which is used as root of the ancestry
 * Added debugFail() template to better locate internal errors
2016-03-19 22:45:24 +01:00
Felix Krause ae933d90a1 Fixes to block scalars and yamlTestSuite
* Properly handle empty block scalars and trailing lines
 * Fixed a bug in yamlTestSuite that led to lots of open file handles
2016-03-18 22:29:35 +01:00
Felix Krause 1c61486739 Fixed small bugs
* allow '!' at beginning of tag URI in %TAG directive
 * recognise \t as start of more indented line in block flow scalar
 * Made testEventParser more robust
2016-03-16 19:20:18 +01:00
Felix Krause 9c251584a0 Fixed YAML test suite to conform to naming changes 2016-03-14 18:20:20 +01:00
Felix Krause 16d1a1bceb Various code style and naming fixes
* Renamed some symbols for consistency, fixes #6:
   - yamlStartSequence -> yamlStartSeq
   - yamlEndSequence   -> yamlEndSeq
   - yamlStartDocument -> yamlStartDoc
   - yamlEndDocument   -> yamlEndDoc
   - yTagMap           -> yTagMapping
 * Improved code formatting at some places
 * Fixed code documentation at some places
 * Added generic objects to TODO list
 * Removed obsolete parsing tests, these are superseeded
   by yaml-dev-kit test suite integration
2016-03-14 18:10:34 +01:00
Felix Krause afc5306da5 event parser: support \b and \t escape sequences 2016-03-11 17:58:15 +01:00
Felix Krause de7f821696 Improved YAML test suite integration
* Support for anchors and aliases
 * Continue with next test on exception
 * Better naming
2016-03-09 20:15:43 +01:00
Felix Krause 121492d4c6 Support updated yaml-dev-kit data layout 2016-03-04 21:23:13 +01:00
Felix Krause 778799e4ff Added option to validate against YAML test suite 2016-03-04 19:10:48 +01:00
Felix Krause 5933605591 Added copyright notices to files where missing 2016-02-27 13:09:50 +01:00
Felix Krause 46913867e2 Presenter: Let user decide about newline style
* Added PresentationOptions object; merged PresentationStyle,
   indentationStep and NewLineStyle in it
 * Updated signatures of relevant procs
 * Implemented user-defined newline style in presenter
2016-02-26 21:55:59 +01:00
Felix Krause 349cb19912 Refactoring of serialization code
* Made some procs/templates private that have been public without need
 * Improved documentation of procs
2016-02-26 21:13:40 +01:00
Felix Krause c9dae4430c Fixes #5 2016-02-25 21:16:03 +01:00
Felix Krause 27670f63c9 Implemented and documented DOM 2016-02-22 21:56:30 +01:00
Felix Krause 33a7f93480 Code cleanup; reduced compiler hints 2016-02-19 18:25:01 +01:00
Felix Krause f2f340c0b6 Fixes #2 2016-02-19 17:31:57 +01:00
Felix Krause 43e10f496a Fixes #3 2016-02-18 22:32:25 +01:00
Felix Krause bc9229d0c5 Fixes #1 2016-02-18 22:14:24 +01:00
Felix Krause 9be97ff386 Added constructChild for better serialization.
- Handle tag and anchor checks and ref types in constructChild
 - Added tests for using custom representObject and constructObject
   procs
 - Code cleanup
2016-02-16 19:24:55 +01:00
Felix Krause 0a7f87a539 Improved docs. Fixed serialization problem.
* Added serialization.txt to doc
 * Fixed rendering problem in api.txt
 * Use explicit tag when ref type renders to a scalar that can be
   parsed to !!null
 * Added test cases for this ref type fix
2016-02-15 22:54:05 +01:00
Felix Krause 02e505959a Added setTagUriForType. Used it. Improved docs. 2016-02-15 19:46:21 +01:00
Felix Krause 325e3ec18f Made serialization part of yaml. Improved doc. 2016-02-12 20:44:38 +01:00
Felix Krause c6c13eb044 Better doc index. YamlStream now an object.
* Also various fixes to serialization and presentation
2016-02-12 19:53:25 +01:00
Felix Krause 32c42054f7 Renamed serialize() to represent() to better conform to YAML spec 2016-02-02 18:19:40 +01:00
Felix Krause e89a9a5b14 Serialization: Support enum types 2016-02-01 20:16:35 +01:00
Felix Krause e967038d06 Support custom types without serialize macro 2016-02-01 19:48:42 +01:00
Felix Krause 620ab55899 Added tests for ref serialization 2016-01-28 22:57:14 +01:00
Felix Krause 5162c310ce Serialization: Better proc names
* renamed serialize to serializeObject and construct to constructObject
 * added new serialize() and construct() procs that handle document
   start & end
 * re-raise AssertionError instead of swallowing it
2016-01-26 20:51:21 +01:00
Felix Krause 4c3f7cd485 Better and more system types for serialization
* Use int[8|16|32|64] and float[32|64] instead of int and float
 * Support uint[8|16|32|64]
 * Support char
2016-01-26 20:00:28 +01:00
Felix Krause 8436026250 Sanitized exception handling in serialization 2016-01-24 20:38:30 +01:00
Felix Krause 42df37bbbe Added JSON construction tests 2016-01-24 19:19:03 +01:00
Felix Krause a08f4c1e4e Sanitized exceptions and raises pragmas
* Added raises pragma to every proc in yaml.nim
 * Properly encapsulate exceptions from YamlStreams
 * Discovered a Nim compiler bug and added a workaround
 * Added possibility to query line, column and line content from
   YamlParser
 * Updated rst documentation
 * Actually call callback in fastparse if available
 * Fixed parsing YAML version
2016-01-24 18:24:09 +01:00
Felix Krause fdcc699768 Removed old lexer/parser impl in favor of new one
* fastparse now used for everything
 * private/[lexer|parser].nim gone
 * Made fastparse use YamlParser object
 * Got all tests working with fastparse
 * Some more smaller changes to API
2016-01-24 11:44:10 +01:00
Felix Krause 971218314e fastparse: made it pass the parsing tests
* Scan for implicit map key as soon as a property is encountered
 * Proper handling of node properties throughout parser
 * Fixed an issue where plain scalars sometimes contained garbage
   when yielded
 * Catch reserved chars @ and `
 * Fixed some test cases
 * Made parser test cases use fastparse
2016-01-23 17:44:50 +01:00
Felix Krause 9c731cb6d1 Refactoring lexer, part 1 2016-01-15 00:06:57 +01:00
Felix Krause 56d3537920 Refactoring: Shorter type names 2016-01-14 22:51:30 +01:00
Felix Krause 551c8b0dd1 Refactoring: Extracted type guessing from lexer 2016-01-14 19:58:38 +01:00
Felix Krause 18753b1a4a Got rid of yamlWarning, use YamlPresenterError
* Added YamlWarningCallback that may be used to capture
   parser warnings
 * Removed yamlWarning as event kind
 * Replaced checks for well-formedness in presenter with asserts
 * Added checks for JSON compatibility of YamlStream in presenter
 * Added proper type hints for special float values in
   serializer to be able to check for them in the presenter
2016-01-05 19:06:55 +01:00
Felix Krause d2baa1749e Got rid of yamlError.
* Replaced yielding yamlError tokens with raising a YamlParserError
 * Renamed sequential.nim to parser.nim because it's the parser (duh)
2016-01-05 18:14:11 +01:00
Felix Krause aa98c5863e Properly handle ytsRootOnly
* Yield tag of custom type serialization when using ytsRootOnly,
   but don't yield tags of map keys or values
 * Yield proper tag of Table[K, V] serialization if requested
 * renamed dumper.nim to presenter.nim to conform to YAML spec
2016-01-04 22:18:55 +01:00
Felix Krause 507c621aaf Implemented local tags for serialization
* Fixed a bug in the lexer where an error would be raised if
   characters not allowed in tag shorthands are used in local tags
 * Fixed processing of object tags for all kinds of root nodes in Parser
 * Improved dumper to output a space after a local tag
 * Renamed some enumeration types to conform better to the YAML spec
 * Added secondaryPrefix to YamlTagLibrary
 * Added possibility to control tag output style independently from
   presentation style in serializer
 * Created local tags for all types that are serialized and use them in
   construction and serialization
2016-01-04 21:46:33 +01:00
Felix Krause a094089fb9 Various improvements
* Better JSON serialization (map bool literals to true/false if
   possible)
 * Fixed a problem where the tag of block sequence would be
   wrongly placed
 * Always output "" when dumping empty strings
 * Added helper functions to create YamlStreamEvents.
 * Moved procs for YamlStreamEvents to private/events.nim
 * renamed dump() to present()
 * Added dump() and load() to yaml.serialization
2015-12-29 18:22:55 +01:00
Felix Krause 9ff93efb11 Implemented basic serialization
* added serialize() procs for some basic types
 * extended make_serializable to generate serialize() proc
2015-12-29 16:10:47 +01:00
Felix Krause dc1a3c0fe2 Can construct basic types and custom objects
* Added construct() procs for some basic types
 * Added macro make_serializable
2015-12-29 15:09:37 +01:00
Felix Krause d828f4ddc5 Added benchmark. Fixed processing empty flow sets. 2015-12-29 00:14:47 +01:00
Felix Krause 238faf82ab Source restructuring, added config.nims
* moved src/* to .
 * added config.nims to build library and run tests
 * reduced compiler warnings
2015-12-28 22:03:16 +01:00
Felix Krause b1e828eae6 Added documentation comments 2015-12-27 23:40:27 +01:00
Felix Krause f2527efd46 Support additional boolean scalars
* on, off, yes, no, literals with leading or complete capital letters
 * added documentation
2015-12-27 21:36:47 +01:00
Felix Krause 2c9d065ecb Support tags for sequences and maps in block style 2015-12-27 17:37:42 +01:00
Felix Krause d7f1e726ab Added dump() and transform()
* Added a hint "mapMayHaveKeyObjects" to yamlMap
 * Added dumper.nim
 * Improved generated documentation a bit
2015-12-27 16:36:32 +01:00
Felix Krause 075cf8b8ef Worked on tag URI interface
* Added YamlTagLibrary
 * adhere to explicit tags in JSON
 * Fixed lexer type hints before YAML flow special characters
2015-12-26 18:40:23 +01:00
Felix Krause ca0f5d1741 Refactoring, less heap objects
* YamlParserEvent -> YamlStreamEvent
 * YamlStreamEvent is no longer a `ref` object. Test suite now
   runs in a small fraction of a second (compared to several
   seconds before)
 * Introduced YamlStream
2015-12-26 13:39:43 +01:00
Felix Krause 2c4e681f0b Finished JSON parser. Restructuring.
* Made JSON parser resolve anchors and aliases
 * Moved exported consts and types to yaml.nim
2015-12-26 13:16:57 +01:00
Felix Krause c83d488886 Added JSON compositor. 2015-12-24 15:21:49 +01:00
Felix Krause e307cbbad5 Pipe type hints through parser. Fixed bugs. 2015-12-23 18:12:51 +01:00
Felix Krause ffcbbf89e6 Restructured source code 2015-12-23 12:35:07 +01:00
Felix Krause 5c0e9f570b Added type hinting in lexer 2015-12-23 10:28:58 +01:00
Felix Krause a9a1a67bc6 Support anchors on empty nodes 2015-12-22 23:35:03 +01:00
Felix Krause 545bff673a Support missing keys/values in maps 2015-12-22 22:28:27 +01:00
Felix Krause ca077e54ca Allow mixing explicit and implicit map keys 2015-12-22 21:08:58 +01:00
Felix Krause c1880b5117 Support tag handle after directives end 2015-12-22 18:51:16 +01:00
Felix Krause f249813b90 Implemented alias resolution
* Parse alias nodes properly
 * Fixed a bug that prevented you from having objects as map keys
 * Use AnchorId for reporting anchors instead of strings
 * Do not use nil strings for anchor and tag
2015-12-22 16:28:35 +01:00
Felix Krause f320449a2d Got tags working 2015-12-21 23:10:42 +01:00
Felix Krause 32f36515e7 Return TagIds instead of strings 2015-12-21 21:58:28 +01:00
Felix Krause 70597105cb Worked on tags
* introduced YamlSequentialParser object that stores
   all known tag URIs
 * Added procs for registering and querying tag URIs
 * Return non-specific tags instead of nil if no tags
   exist in source
2015-12-21 21:40:27 +01:00
Felix Krause edec7ece37 Implemented block scalars 2015-12-17 21:44:41 +01:00
Felix Krause 3ca3081e92 Added support for multiline plain scalars 2015-12-14 21:26:34 +01:00
Felix Krause b56f9cb537 Refactoring of parser. 2015-12-11 22:55:21 +01:00
Felix Krause 01416f61be Improved mixing block and flow content 2015-12-10 23:02:06 +01:00
Felix Krause ed7176131e Implemented flow style parsing
* Fixed lexer error where comma did not get properly processed
 * Implemented flow style in parser
 * Added tests
2015-12-10 22:28:57 +01:00
Felix Krause e642e41f90 Bug fixes in lexer and parser
* Lexer: column now always points to start of token
 * Lexer: added ability to compile with -d:yamlDebug for debug output
 * Parser: Correctly handle nested sequences and maps
 * Tests: Added parser tests for nested objects
2015-12-10 20:53:43 +01:00
Felix Krause 73ce41bbef Added parsing tests; got basic parsing working 2015-12-07 22:09:57 +01:00
Felix Krause ada4a36e6e Lexer: Fixed parsing verbatim tags 2015-12-07 19:09:02 +01:00
Felix Krause 26c1c07567 No position in token; line and column in lexer 2015-11-30 20:36:55 +01:00
Felix Krause 9a3cf9a524 Renamed *LexerEvent* to *LexerToken* 2015-11-30 19:52:01 +01:00
Felix Krause 8493015042 Implemented anchors and aliases 2015-11-29 22:43:10 +01:00
Felix Krause f876c845b7 Own token kinds for every special char, more tests 2015-11-29 22:27:05 +01:00
Felix Krause 71456c6bed Fixed unicode escaping; added tests 2015-11-29 21:01:22 +01:00
Felix Krause f793247a41 Fixed line break handling 2015-11-29 16:50:27 +01:00
Felix Krause 9cba968c1e Separation between directives and content; tests 2015-11-29 15:42:41 +01:00
Felix Krause a7c159933b Initial commit 2015-11-27 23:42:11 +01:00