Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a basic decoder #2

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft

Conversation

dinkelspiel
Copy link

@dinkelspiel dinkelspiel commented Jun 6, 2024

This pull requests implements a basic YAML decoder for issue #1 that should cover most standard YAML documents. A feature list can be found below. It should be sufficient to cover many common yaml files like docker-compose files and kubernetes configs.

The YAML test suite in the test directory has a preliminary implementation but is commented out as the encoded output of a cymbal yaml object does not match the expected output.

Basic Syntax

  • Comments (#)
  • Indentation (spaces, not tabs)

Data Types

  • Scalars
    • Plain Scalars
    • Quoted Scalars
      • Single quotes
      • Double quotes
  • Multiline Strings
    • Literal Block Scalar (|)
    • Folded Block Scalar (>)
  • Numbers
    • Integers
    • Floating-point
    • Exponential
    • Octal
    • Hexadecimal
  • Boolean
    • true / false
  • Null
    • null
    • ~

Collections

  • Sequences (Lists)
    • Block notation (-)
    • Inline notation ([ ])
  • Mappings (Dictionaries)
    • Block notation (:)
    • Inline notation ({ })

Advanced Features

  • Anchors and Aliases
    • Anchor (&)
    • Alias (*)
  • Merge Keys
    • Merging mappings with <<
  • Tags
    • Explicit data type tags (!!)
    • Custom tags

Directives

  • YAML version directive (%YAML)
  • Tag directive (%TAG)

Document Markers

  • Start of document marker (---)
  • End of document marker (...)

Flow Styles

  • Flow mappings ({key1: value1, key2: value2})
  • Flow sequences ([item1, item2, item3])

Special Features

  • Custom Tags (!mytag)
  • Type Coercion (automatic type conversion)
  • Binary Data (!!binary)
  • Date and Time (ISO 8601 format)

@dinkelspiel dinkelspiel changed the title Implement a basic decoder (#1) Implement a basic decoder Jun 6, 2024
Copy link
Owner

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heroic effort! Thank you!! I've left some notes inline

Could you also use variables to avoid ever having case case and to avoid complex operators split over multiple lines. Thank you

.gitmodules Outdated Show resolved Hide resolved
src/cymbal.gleam Outdated Show resolved Hide resolved
// }
// _ -> False
// }
// }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this code is commented out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Their encoded yaml and the encoded yaml returned from cymbal don't match so no tests are passing there atm. It will need some tweaking but it's just commented so I could work on the other tests in the meantime. I will get to it at some point but I haven't been able to because of school/work

@lpil lpil marked this pull request as draft July 25, 2024 13:14
@dinkelspiel
Copy link
Author

I wonder if implementing the restricted subset StrictYAML would be preferrable. It is of course up to the author but the implicit behaviors that comes from the yaml 1.2 and 1.1 spec could be argued shouldn't be implemented not that we have the chance.

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

Successfully merging this pull request may close these issues.

2 participants