Coder Social home page Coder Social logo

rsn's Introduction

rsn - Rust Notation

This crate is very early in development and is not ready for consumption.

A UTF-8 based text format that looks very similar to valid Rust code.

The syntax differs from valid Rust code for:

  • Map literals. Rust has no syntax for map literals.
  • Enum Variants being used without the type name -- Red vs Color::Red
    • This is technically valid Rust syntax if use Color::* is present.
  • Infinity and Not-A-Number floats are represented as +Inf/-Inf/+NaN/-NaN.

The rules for parsing literals should match Rust's rules as closely as possible.

no_std support

This crate supports no_std targets that support the alloc crate.

Data Types

  • Integers (42, 0xFF, 0o77, ob101)

  • Floats (42., 3.14, `)

  • Bool (true, false)

  • Character ('a', '\'')

  • Byte (b'a', b'\'')

  • String ("hello, world")

  • Raw Strings (r#"They said, "Hello World!""#)

  • Byte Strings (b"hello, world")

  • Struct

    • Ident or Raw Ident (r#foo)
    • Map or Tuple
  • Map

    • List of <Value>: <Value> pairs, delimited by comma
    • Trailing comma is optional
  • Tuple (empty tuple = Unit)

    • List of <Value>s, delimited by comma
    • Trailing comma is optional
  • Array

    • List of <Value>s, delimited by comma
    • Trailing comma is optional
  • Comments // and /* */

  • Potential Extensions via #[] syntax

    • Semi-strict comma-delimited list
    • #[foo(...), bar = ...,]
    • All braces/brackets/parens must be paired correctly?

Why not Ron?

Ron is a great format. There were a few design decisions that led to this very-similar-yet-not-the-same format being invented:

  • ron differentiates between Tuples and Lists, while rsn treats all sequences the same.
  • ron uses a different syntax for structures and maps. rsn uses the same syntax for both concepts.
  • ron has special support for Option<T>. rsn treats Option<T> like any other enum.
  • ron's parsing rules are close but not the same as Rust, while rsn attempts to match implementations:
    • Rust allows unicode identifiers
    • Rust allows additional whitespace characters
    • Rust allows _ in float literals
    • Rust allows for raw line endings to be escaped in string literals.
    • Rust supports multi-line comments /* ... */
    • Rust supports byte strings and byte literals, while Ron elected to use base64 encoded strings for byte values.

rsn's People

Contributors

ecton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.