Build production-ready editor authoring workflows
CI / Format, lint, test, build (push) Waiting to run
CI / Format, lint, test, build (push) Waiting to run
This commit is contained in:
1 parent
cc1fa6ea3b
commit
0553a85220
163 files changed
+34547
-1565
No files matched your search
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "961f66a7ecb83e674b2ac0e52a3574f5637e7dab"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
tests/input/* binary
|
||||
@@ -0,0 +1,2 @@
|
||||
/target
|
||||
/Cargo.lock
|
||||
Vendored
+59
@@ -0,0 +1,59 @@
|
||||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
# Blacksite modifications are documented in PATCH.md.
|
||||
|
||||
[package]
|
||||
edition = "2021"
|
||||
name = "ron-edit"
|
||||
version = "0.2.0"
|
||||
description = "ron parser preserving all syntax information"
|
||||
documentation = "https://docs.rs/ron-edit"
|
||||
readme = "README.md"
|
||||
keywords = ["parser"]
|
||||
categories = ["encoding"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/ModProg/ron-edit"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = [
|
||||
"--cfg",
|
||||
"docsrs",
|
||||
]
|
||||
|
||||
[dependencies.const_format]
|
||||
version = "0.2.30"
|
||||
|
||||
[dependencies.derive_more]
|
||||
version = "0.99.17"
|
||||
|
||||
[dependencies.macro_rules_attribute]
|
||||
version = "0.1.3"
|
||||
|
||||
[dependencies.nom]
|
||||
version = "7.1.3"
|
||||
|
||||
[dependencies.unicode-ident]
|
||||
version = "1.0.8"
|
||||
|
||||
[dev-dependencies.include_dir]
|
||||
version = "0.7.3"
|
||||
|
||||
[dev-dependencies.insta]
|
||||
version = "1.28.0"
|
||||
features = ["ron"]
|
||||
|
||||
[dev-dependencies.ron]
|
||||
version = "0.8.0"
|
||||
|
||||
[dev-dependencies.serde]
|
||||
version = "1.0.154"
|
||||
features = ["derive"]
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
[package]
|
||||
name = "ron-edit"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
categories = ["encoding"]
|
||||
description = "ron parser preserving all syntax information"
|
||||
keywords = ["parser"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/ModProg/ron-edit"
|
||||
documentation = "https://docs.rs/ron-edit"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[dev-dependencies]
|
||||
include_dir = "0.7.3"
|
||||
insta = { version = "1.28.0", features = ["ron"] }
|
||||
ron = "0.8.0"
|
||||
serde = { version = "1.0.154", features = ["derive"] }
|
||||
|
||||
|
||||
[profile.dev.package.insta]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.similar]
|
||||
opt-level = 3
|
||||
|
||||
[dependencies]
|
||||
const_format = "0.2.30"
|
||||
derive_more = "0.99.17"
|
||||
macro_rules_attribute = "0.1.3"
|
||||
nom = "7.1.3"
|
||||
unicode-ident = "1.0.8"
|
||||
Vendored
+201
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a peretual,
|
||||
worldwide, non-exclusive, no-cpharge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides it s Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Roland Fredenhagen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
# ron-edit 0.2.0 (patched)
|
||||
|
||||
Vendored from the `ron-edit` 0.2.0 crates.io release, corresponding to
|
||||
upstream commit `961f66a7ecb83e674b2ac0e52a3574f5637e7dab`.
|
||||
|
||||
- Upstream: https://github.com/ModProg/ron-edit
|
||||
- License: MIT OR Apache-2.0
|
||||
- Unmodified license texts are retained as `LICENSE-MIT` and `LICENSE-APACHE`.
|
||||
|
||||
Blacksite carries these changes:
|
||||
|
||||
- Parse anonymous structs before tuples so component values such as Bevy
|
||||
transforms retain their named fields.
|
||||
- Reject an integer parse when the following token continues a floating-point
|
||||
value, preventing values such as `1.0` from being consumed as `1` plus a
|
||||
trailing token.
|
||||
- Allow the upstream lifetime-syntax lint while the parser API retains its
|
||||
original borrowed-value signatures.
|
||||
- Format the source with the workspace's stable Rust toolchain. The upstream
|
||||
nightly-only `rustfmt.toml` and package-local profile tuning are omitted.
|
||||
|
||||
The patch supports lossless scene component/resource RON editing in the scene
|
||||
document layer. Remove this vendor patch once a released upstream version
|
||||
contains the parser fixes and passes Blacksite's scene document round-trip and
|
||||
prefab source-edit regression tests.
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
# ron-edit
|
||||
|
||||
[](https://github.com/ModProg/ron-edit/actions/workflows/test.yaml)
|
||||
[](https://crates.io/crates/ron-edit)
|
||||
[](https://docs.rs/ron-edit)
|
||||
[](https://modprog.github.io/ron-edit/ron_edit/)
|
||||
|
||||
Very much WIP ron parser preserving whitespace information.
|
||||
Vendored
+402
@@ -0,0 +1,402 @@
|
||||
// Blacksite modifications are documented in ../PATCH.md.
|
||||
//! Nom parser trying to preserve all information
|
||||
//!
|
||||
//! Probably the "AST" structure will be reworked quite a bit.
|
||||
#![allow(mismatched_lifetime_syntaxes)]
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
use derive_more::Display;
|
||||
use macro_rules_attribute::{apply, attribute_alias};
|
||||
use nom::branch::*;
|
||||
use nom::bytes::complete::*;
|
||||
use nom::character::complete::*;
|
||||
use nom::combinator::*;
|
||||
use nom::error::{context, VerboseError};
|
||||
use nom::multi::*;
|
||||
use nom::sequence::*;
|
||||
use nom::{Finish, Parser};
|
||||
#[cfg(test)]
|
||||
use serde::Serialize;
|
||||
use unicode_ident::{is_xid_continue, is_xid_start};
|
||||
pub use value::{Char, Int, List, Map, MapItem, NamedField, Str, Struct, Tuple, Value};
|
||||
|
||||
type Error<'a> = VerboseError<&'a str>;
|
||||
type IResult<'a, T> = nom::IResult<&'a str, T, Error<'a>>;
|
||||
|
||||
mod value;
|
||||
|
||||
attribute_alias! {
|
||||
#[apply(ast)] =
|
||||
#[cfg_attr(test, derive(Serialize))]
|
||||
#[derive(Debug, PartialEq)];
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
pub struct File<'s> {
|
||||
pub extentions: Vec<WsLead<'s, Attribute<'s>>>,
|
||||
pub value: WsLead<'s, Value<'s>>,
|
||||
pub trailing_ws: Whitespace<'s>,
|
||||
}
|
||||
|
||||
impl Display for File<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
self.extentions.iter().try_for_each(|e| write!(f, "{e}"))?;
|
||||
write!(f, "{}{}", self.value, self.trailing_ws)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> TryFrom<&'s str> for File<'s> {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(s: &'s str) -> Result<Self, Self::Error> {
|
||||
match file(s).finish() {
|
||||
Ok(("", file)) => Ok(file),
|
||||
Ok((rem, _)) => Err(format!("unexpected: {rem}")),
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
#[display(fmt = "#{after_pound}!\
|
||||
{after_exclamation}[{after_bracket}enable{after_enable}({extentions}){after_paren}]")]
|
||||
pub struct Attribute<'s> {
|
||||
pub after_pound: Whitespace<'s>,
|
||||
pub after_exclamation: Whitespace<'s>,
|
||||
pub after_bracket: Whitespace<'s>,
|
||||
pub after_enable: Whitespace<'s>,
|
||||
pub extentions: Separated<'s, &'s str>,
|
||||
pub after_paren: Whitespace<'s>,
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
pub struct WsLead<'s, T> {
|
||||
pub leading: Whitespace<'s>,
|
||||
pub content: T,
|
||||
}
|
||||
impl<T: Display> Display for WsLead<'_, T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}{}", self.leading, self.content)
|
||||
}
|
||||
}
|
||||
fn ws_lead<'a, T>(
|
||||
t: impl Parser<&'a str, T, Error<'a>>,
|
||||
) -> impl Parser<&'a str, WsLead<'a, T>, Error<'a>> {
|
||||
map(pair(ws, t), |(leading, content)| WsLead {
|
||||
leading,
|
||||
content,
|
||||
})
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Default)]
|
||||
pub struct WsFollowed<'s, T> {
|
||||
pub content: T,
|
||||
pub following: Whitespace<'s>,
|
||||
}
|
||||
impl<T: Display> Display for WsFollowed<'_, T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}{}", self.content, self.following)
|
||||
}
|
||||
}
|
||||
fn ws_followed<'a, T>(
|
||||
t: impl Parser<&'a str, T, Error<'a>>,
|
||||
) -> impl Parser<&'a str, WsFollowed<'a, T>, Error<'a>> {
|
||||
map(pair(t, ws), |(content, following)| WsFollowed {
|
||||
content,
|
||||
following,
|
||||
})
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Default)]
|
||||
pub struct WsWrapped<'s, T> {
|
||||
pub leading: Whitespace<'s>,
|
||||
pub content: T,
|
||||
pub following: Whitespace<'s>,
|
||||
}
|
||||
impl<T: Display> Display for WsWrapped<'_, T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}{}{}", self.leading, self.content, self.following)
|
||||
}
|
||||
}
|
||||
fn ws_wrapped<'a, T>(
|
||||
t: impl Parser<&'a str, T, Error<'a>>,
|
||||
) -> impl Parser<&'a str, WsWrapped<'a, T>, Error<'a>> {
|
||||
map(tuple((ws, t, ws)), |(leading, content, following)| {
|
||||
WsWrapped {
|
||||
leading,
|
||||
content,
|
||||
following,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
pub enum Ws<'s> {
|
||||
LineComment(&'s str),
|
||||
Space(&'s str),
|
||||
BlockComment(&'s str),
|
||||
}
|
||||
impl Display for Ws<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Ws::LineComment(c) => write!(f, "//{c}"),
|
||||
Ws::Space(s) => write!(f, "{s}"),
|
||||
Ws::BlockComment(c) => write!(f, "/*{c}*/"),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Ws<'_> {
|
||||
pub fn is_comment(&self) -> bool {
|
||||
!matches!(self, Self::Space(_))
|
||||
}
|
||||
|
||||
pub fn is_line_comment(&self) -> bool {
|
||||
matches!(self, Self::LineComment(_))
|
||||
}
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Default)]
|
||||
pub struct Whitespace<'s>(pub Vec<Ws<'s>>);
|
||||
|
||||
impl Display for Whitespace<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
self.0.iter().try_for_each(|ws| write!(f, "{ws}"))
|
||||
}
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
pub struct Separated<'s, T> {
|
||||
pub values: Vec<WsWrapped<'s, T>>,
|
||||
/// When formatting with [`Display`] comma is only shown when
|
||||
/// [`Self::values`] is not empty.
|
||||
pub trailing_comma: bool,
|
||||
pub trailing_ws: Whitespace<'s>,
|
||||
}
|
||||
|
||||
impl<T: Display> Display for Separated<'_, T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
let Self {
|
||||
values,
|
||||
trailing_comma,
|
||||
trailing_ws,
|
||||
} = self;
|
||||
let Some((last, rest)) = values.split_last() else {
|
||||
return write!(f, "{trailing_ws}");
|
||||
};
|
||||
rest.iter().try_for_each(|i| write!(f, "{i},"))?;
|
||||
write!(f, "{last}")?;
|
||||
if *trailing_comma {
|
||||
write!(f, ",")?;
|
||||
}
|
||||
write!(f, "{trailing_ws}")
|
||||
}
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
pub struct ExtentionIdent {}
|
||||
|
||||
fn file(input: &str) -> IResult<File> {
|
||||
map(
|
||||
tuple((
|
||||
context("attributes", many0(ws_lead(extention_attr))),
|
||||
context("value", ws_lead(value::value)),
|
||||
ws,
|
||||
)),
|
||||
|(extentions, value, trailing_ws)| File {
|
||||
extentions,
|
||||
value,
|
||||
trailing_ws,
|
||||
},
|
||||
)(input)
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn dbg_dmp<'a, O>(
|
||||
context: impl Display,
|
||||
mut p: impl Parser<&'a str, O, Error<'a>>,
|
||||
) -> impl FnMut(&'a str) -> IResult<O> {
|
||||
move |s: &str| match p.parse(s) {
|
||||
Err(nom::Err::Error(c)) => {
|
||||
println!("{}: Parsing Error: {} at:\n{:?}", context, c, s);
|
||||
Err(nom::Err::Error(c))
|
||||
}
|
||||
Err(e) => {
|
||||
println!("{}: Error({}) at:\n{:?}", context, e, s);
|
||||
Err(e)
|
||||
}
|
||||
a => a,
|
||||
}
|
||||
}
|
||||
|
||||
fn extention_attr(input: &str) -> IResult<Attribute> {
|
||||
map(
|
||||
tuple((
|
||||
char('#'),
|
||||
ws,
|
||||
char('!'),
|
||||
ws,
|
||||
char('['),
|
||||
ws,
|
||||
tag("enable"),
|
||||
ws,
|
||||
char('('),
|
||||
separated(ident),
|
||||
char(')'),
|
||||
ws,
|
||||
char(']'),
|
||||
)),
|
||||
|(
|
||||
_,
|
||||
after_pound,
|
||||
_,
|
||||
after_exclamation,
|
||||
_,
|
||||
after_bracket,
|
||||
_,
|
||||
after_ident,
|
||||
_,
|
||||
extentions,
|
||||
_,
|
||||
after_paren,
|
||||
_,
|
||||
)| {
|
||||
Attribute {
|
||||
after_pound,
|
||||
after_exclamation,
|
||||
extentions,
|
||||
after_bracket,
|
||||
after_enable: after_ident,
|
||||
after_paren,
|
||||
}
|
||||
},
|
||||
)(input)
|
||||
}
|
||||
|
||||
fn ident(input: &str) -> IResult<&str> {
|
||||
alt((
|
||||
recognize(pair(
|
||||
tag("r#"),
|
||||
cut(many1(alt((take_while1(is_xid_continue), is_a("+-."))))),
|
||||
)),
|
||||
recognize(pair(
|
||||
// TODO make issue about adding a take_one(fn(char)->bool)
|
||||
alt((tag("_"), take_while_m_n(1, 1, is_xid_start))),
|
||||
take_while(is_xid_continue),
|
||||
)),
|
||||
))(input)
|
||||
}
|
||||
|
||||
fn block_comment(input: &str) -> IResult<Ws> {
|
||||
map(
|
||||
delimited(
|
||||
tag("/*"),
|
||||
recognize(many0(alt((
|
||||
is_not("*/"),
|
||||
recognize(block_comment),
|
||||
take_until1("*/"),
|
||||
)))),
|
||||
tag("*/"),
|
||||
),
|
||||
Ws::BlockComment,
|
||||
)(input)
|
||||
}
|
||||
|
||||
fn ws(input: &str) -> IResult<Whitespace> {
|
||||
map(
|
||||
many0(alt((
|
||||
map(is_a("\n\t\r "), Ws::Space),
|
||||
map(
|
||||
preceded(tag("//"), recognize(pair(is_not("\n"), line_ending))),
|
||||
Ws::LineComment,
|
||||
),
|
||||
block_comment,
|
||||
))),
|
||||
Whitespace,
|
||||
)(input)
|
||||
}
|
||||
|
||||
fn separated<'a, T, P: Parser<&'a str, T, Error<'a>>>(
|
||||
p: P,
|
||||
) -> impl FnMut(&'a str) -> IResult<Separated<T>> {
|
||||
context(
|
||||
"separated",
|
||||
map(
|
||||
tuple((
|
||||
separated_list0(char(','), ws_wrapped(p)),
|
||||
opt(char(',')),
|
||||
ws,
|
||||
)),
|
||||
|(values, trailing_comma, trailing_ws)| Separated {
|
||||
values,
|
||||
trailing_comma: trailing_comma.is_some(),
|
||||
trailing_ws,
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
struct FormatOption<'a, T>(&'a Option<T>);
|
||||
impl<T: Display> Display for FormatOption<'_, T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match self.0 {
|
||||
Some(t) => write!(f, "{t}"),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use include_dir::include_dir;
|
||||
|
||||
use super::*;
|
||||
|
||||
const INPUTS: include_dir::Dir = include_dir!("$CARGO_MANIFEST_DIR/tests/input");
|
||||
|
||||
#[test]
|
||||
fn whitespace() {
|
||||
assert_eq!(
|
||||
block_comment("/* a */ ").finish().unwrap(),
|
||||
(" ", Ws::BlockComment(" a ".into()))
|
||||
);
|
||||
assert_eq!(
|
||||
block_comment("/* a /* inner */ */ ").finish().unwrap(),
|
||||
(" ", Ws::BlockComment(" a /* inner */ ".into()))
|
||||
);
|
||||
assert_eq!(
|
||||
ws("/* *//* a /* inner */ */").finish().unwrap(),
|
||||
(
|
||||
"",
|
||||
Whitespace(vec![
|
||||
Ws::BlockComment(" ".into()),
|
||||
Ws::BlockComment(" a /* inner */ ".into())
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ensure_valid_ron() {
|
||||
for file in INPUTS.entries() {
|
||||
let _: ron::Value = ron::de::from_bytes(file.as_file().unwrap().contents()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse() {
|
||||
for file in INPUTS.entries() {
|
||||
let contents = file.as_file().unwrap().contents_utf8().unwrap();
|
||||
let ron: File = contents.try_into().map_err(|e| eprintln!("{e}")).unwrap();
|
||||
|
||||
assert_eq!(ron.to_string(), contents);
|
||||
|
||||
insta::with_settings!({snapshot_path => "../tests/snapshots"},{
|
||||
insta::assert_ron_snapshot!(file.path().display().to_string(), ron);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+240
@@ -0,0 +1,240 @@
|
||||
// Blacksite modifications are documented in ../PATCH.md.
|
||||
use crate::*;
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
pub enum Value<'s> {
|
||||
Int(Int<'s>),
|
||||
Float(Float<'s>),
|
||||
Str(Str<'s>),
|
||||
Char(Char<'s>),
|
||||
Bool(bool),
|
||||
List(List<'s>),
|
||||
Map(Map<'s>),
|
||||
Unit(&'s str),
|
||||
Tuple(Tuple<'s>),
|
||||
Struct(Struct<'s>),
|
||||
}
|
||||
pub(crate) fn value(input: &str) -> IResult<Value> {
|
||||
alt((
|
||||
map(value_int, Value::Int),
|
||||
map(value_float, Value::Float),
|
||||
map(value_str, Value::Str),
|
||||
map(value_char, Value::Char),
|
||||
map(value_list, Value::List),
|
||||
map(value_map, Value::Map),
|
||||
map(value_struct, Value::Struct),
|
||||
map(value_tuple, Value::Tuple),
|
||||
map(ident, Value::Unit),
|
||||
))(input)
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
pub struct Int<'s>(&'s str);
|
||||
fn value_int(s: &str) -> IResult<Int> {
|
||||
map(
|
||||
recognize(tuple((
|
||||
sign,
|
||||
alt((
|
||||
is_a("0123456789_"),
|
||||
preceded(
|
||||
char('0'),
|
||||
cut(preceded(is_a("box"), is_a("0123456789ABCDEFabcdef_"))),
|
||||
),
|
||||
)),
|
||||
not(peek(one_of(".eE"))),
|
||||
))),
|
||||
Int,
|
||||
)(s)
|
||||
}
|
||||
|
||||
fn sign(s: &str) -> IResult<Option<char>> {
|
||||
opt(alt((char('+'), char('-'))))(s)
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
pub struct Float<'s>(&'s str);
|
||||
fn value_float(s: &str) -> IResult<Float> {
|
||||
map(
|
||||
// TODO test `double`
|
||||
recognize(tuple((
|
||||
opt(alt((char('+'), char('-')))),
|
||||
alt((
|
||||
tag("inf"),
|
||||
tag("NaN"),
|
||||
recognize(tuple((
|
||||
alt((
|
||||
recognize(tuple((digit1, opt(tuple((char('.'), digit0)))))),
|
||||
recognize(tuple((char('.'), digit1))),
|
||||
)),
|
||||
opt(tuple((alt((char('e'), char('E'))), sign, digit1))),
|
||||
))),
|
||||
)),
|
||||
))),
|
||||
Float,
|
||||
)(s)
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
pub enum Str<'s> {
|
||||
#[display(fmt = "\"{_0}\"")]
|
||||
Baked(&'s str),
|
||||
#[display(fmt = "r{0}\"{content}\"{0}", "\"#\".repeat(*pounds)")]
|
||||
Raw { pounds: usize, content: &'s str },
|
||||
}
|
||||
fn value_str(s: &str) -> IResult<Str> {
|
||||
alt((
|
||||
map(
|
||||
preceded(
|
||||
char::<&str, Error>('"'),
|
||||
cut(terminated(
|
||||
recognize(many0(alt((
|
||||
tag("\\\""),
|
||||
tag("\\\\"),
|
||||
tag("\\"),
|
||||
is_not("\\\""),
|
||||
)))),
|
||||
char('"'),
|
||||
)),
|
||||
),
|
||||
Str::Baked,
|
||||
),
|
||||
map(raw_string, |(pounds, content)| Str::Raw { pounds, content }),
|
||||
))(s)
|
||||
}
|
||||
|
||||
fn raw_string(s: &str) -> IResult<(usize, &str)> {
|
||||
let (s, _) = char('r')(s)?;
|
||||
let (s, pounds) = many0_count(char('#'))(s)?;
|
||||
let terminator = format!("\"{}", "#".repeat(pounds));
|
||||
let res = preceded(
|
||||
char('"'),
|
||||
cut(terminated(
|
||||
take_until(terminator.as_str()),
|
||||
tag(terminator.as_str()),
|
||||
)),
|
||||
)
|
||||
.map(|content| (pounds, content))
|
||||
.parse(s);
|
||||
res
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
#[display(fmt = "'{_0}'")]
|
||||
pub struct Char<'s>(pub &'s str);
|
||||
fn value_char(s: &str) -> IResult<Char> {
|
||||
map(
|
||||
preceded(
|
||||
char::<&str, Error>('\''),
|
||||
cut(terminated(tag("\\'").or(is_not("'")), char('\''))),
|
||||
),
|
||||
Char,
|
||||
)(s)
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
#[display(fmt = "[{_0}]")]
|
||||
pub struct List<'s>(pub Separated<'s, Value<'s>>);
|
||||
fn value_list(s: &str) -> IResult<List> {
|
||||
map(
|
||||
preceded(char('['), cut(terminated(separated(value), char(']')))),
|
||||
List,
|
||||
)(s)
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
#[display(fmt = "{key}{after_key}:{value}")]
|
||||
pub struct MapItem<'s> {
|
||||
pub key: Value<'s>,
|
||||
pub after_key: Whitespace<'s>,
|
||||
pub value: WsLead<'s, Value<'s>>,
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
#[display(fmt = "{{{_0}}}")]
|
||||
pub struct Map<'s>(pub Separated<'s, MapItem<'s>>);
|
||||
|
||||
fn value_map(s: &str) -> IResult<Map> {
|
||||
context(
|
||||
"map",
|
||||
map(
|
||||
preceded(
|
||||
char('{'),
|
||||
cut(terminated(
|
||||
separated(tuple((value, ws, char(':'), ws_lead(value))).map(
|
||||
|(key, after_key, _, value)| MapItem {
|
||||
key,
|
||||
after_key,
|
||||
value,
|
||||
},
|
||||
)),
|
||||
char('}'),
|
||||
)),
|
||||
),
|
||||
Map,
|
||||
),
|
||||
)(s)
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
#[display(fmt = "{}({fields})", "FormatOption(ident)")]
|
||||
pub struct Tuple<'s> {
|
||||
pub ident: Option<WsFollowed<'s, &'s str>>,
|
||||
pub fields: Separated<'s, Value<'s>>,
|
||||
}
|
||||
fn value_tuple(s: &str) -> IResult<Tuple> {
|
||||
map(
|
||||
pair(
|
||||
opt(ws_followed(ident)),
|
||||
delimited(char('('), separated(value), char(')')),
|
||||
),
|
||||
|(ident, fields)| Tuple { ident, fields },
|
||||
)(s)
|
||||
}
|
||||
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
#[display(fmt = "{key}{after_key}:{value}")]
|
||||
pub struct NamedField<'s> {
|
||||
pub key: &'s str,
|
||||
pub after_key: Whitespace<'s>,
|
||||
pub value: WsLead<'s, Value<'s>>,
|
||||
}
|
||||
#[apply(ast)]
|
||||
#[derive(Display)]
|
||||
#[display(fmt = "{}({fields})", "FormatOption(ident)")]
|
||||
pub struct Struct<'s> {
|
||||
pub ident: Option<WsFollowed<'s, &'s str>>,
|
||||
pub fields: Separated<'s, NamedField<'s>>,
|
||||
}
|
||||
fn value_struct(s: &str) -> IResult<Struct> {
|
||||
context(
|
||||
"value struct",
|
||||
map(
|
||||
pair(
|
||||
opt(ws_followed(ident)),
|
||||
delimited(
|
||||
char('('),
|
||||
separated(map(
|
||||
tuple((ident, terminated(ws, char(':')), ws_lead(value))),
|
||||
|(key, after_key, value)| NamedField {
|
||||
key,
|
||||
after_key,
|
||||
value,
|
||||
},
|
||||
)),
|
||||
char(')'),
|
||||
),
|
||||
),
|
||||
|(ident, fields)| Struct { ident, fields },
|
||||
),
|
||||
)(s)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
(
|
||||
// File containing \r\n endings
|
||||
something: 10
|
||||
)
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
(
|
||||
value: "string",
|
||||
value: inf,
|
||||
value: +NaN,
|
||||
map: {
|
||||
A: "hello",
|
||||
[1, 2]: Something
|
||||
},
|
||||
r#12+10.3-x: "five"
|
||||
)
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
# // a comment
|
||||
! [ enable
|
||||
( unwrap_newtypes
|
||||
, implicit_some)
|
||||
]
|
||||
// Line Comment
|
||||
/* block */
|
||||
/* Block Comment /* Nested Block Comment */ */
|
||||
(
|
||||
value
|
||||
|
||||
: "hello" // comment
|
||||
,
|
||||
something_else /* */: "hi"
|
||||
)
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
source: src/lib.rs
|
||||
expression: ron
|
||||
---
|
||||
File(
|
||||
extentions: [],
|
||||
value: WsLead(
|
||||
leading: Whitespace([]),
|
||||
content: Struct(Struct(
|
||||
ident: None,
|
||||
fields: Separated(
|
||||
values: [
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\r\n "),
|
||||
LineComment(" File containing \\r\\n endings \r\n"),
|
||||
Space(" "),
|
||||
]),
|
||||
content: NamedField(
|
||||
key: "something",
|
||||
after_key: Whitespace([]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Int(Int("10")),
|
||||
),
|
||||
),
|
||||
following: Whitespace([
|
||||
Space("\r\n"),
|
||||
]),
|
||||
),
|
||||
],
|
||||
trailing_comma: false,
|
||||
trailing_ws: Whitespace([]),
|
||||
),
|
||||
)),
|
||||
),
|
||||
trailing_ws: Whitespace([
|
||||
Space("\r\n"),
|
||||
]),
|
||||
)
|
||||
@@ -0,0 +1,160 @@
|
||||
---
|
||||
source: src/lib.rs
|
||||
expression: ron
|
||||
---
|
||||
File(
|
||||
extentions: [],
|
||||
value: WsLead(
|
||||
leading: Whitespace([]),
|
||||
content: Struct(Struct(
|
||||
ident: None,
|
||||
fields: Separated(
|
||||
values: [
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
content: NamedField(
|
||||
key: "value",
|
||||
after_key: Whitespace([]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Str(Baked("string")),
|
||||
),
|
||||
),
|
||||
following: Whitespace([]),
|
||||
),
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
content: NamedField(
|
||||
key: "value",
|
||||
after_key: Whitespace([]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Float(Float("inf")),
|
||||
),
|
||||
),
|
||||
following: Whitespace([]),
|
||||
),
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
content: NamedField(
|
||||
key: "value",
|
||||
after_key: Whitespace([]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Float(Float("+NaN")),
|
||||
),
|
||||
),
|
||||
following: Whitespace([]),
|
||||
),
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
content: NamedField(
|
||||
key: "map",
|
||||
after_key: Whitespace([]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Map(Map(Separated(
|
||||
values: [
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
content: MapItem(
|
||||
key: Unit("A"),
|
||||
after_key: Whitespace([]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Str(Baked("hello")),
|
||||
),
|
||||
),
|
||||
following: Whitespace([]),
|
||||
),
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
content: MapItem(
|
||||
key: List(List(Separated(
|
||||
values: [
|
||||
WsWrapped(
|
||||
leading: Whitespace([]),
|
||||
content: Int(Int("1")),
|
||||
following: Whitespace([]),
|
||||
),
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Int(Int("2")),
|
||||
following: Whitespace([]),
|
||||
),
|
||||
],
|
||||
trailing_comma: false,
|
||||
trailing_ws: Whitespace([]),
|
||||
))),
|
||||
after_key: Whitespace([]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Unit("Something"),
|
||||
),
|
||||
),
|
||||
following: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
),
|
||||
],
|
||||
trailing_comma: false,
|
||||
trailing_ws: Whitespace([]),
|
||||
))),
|
||||
),
|
||||
),
|
||||
following: Whitespace([]),
|
||||
),
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
content: NamedField(
|
||||
key: "r#12+10.3-x",
|
||||
after_key: Whitespace([]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Str(Baked("five")),
|
||||
),
|
||||
),
|
||||
following: Whitespace([
|
||||
Space("\n"),
|
||||
]),
|
||||
),
|
||||
],
|
||||
trailing_comma: false,
|
||||
trailing_ws: Whitespace([]),
|
||||
),
|
||||
)),
|
||||
),
|
||||
trailing_ws: Whitespace([
|
||||
Space("\n"),
|
||||
]),
|
||||
)
|
||||
@@ -0,0 +1,117 @@
|
||||
---
|
||||
source: src/lib.rs
|
||||
expression: ron
|
||||
---
|
||||
File(
|
||||
extentions: [
|
||||
WsLead(
|
||||
leading: Whitespace([]),
|
||||
content: Attribute(
|
||||
after_pound: Whitespace([
|
||||
Space(" "),
|
||||
LineComment(" a comment\n"),
|
||||
Space(" "),
|
||||
]),
|
||||
after_exclamation: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
after_bracket: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
after_enable: Whitespace([
|
||||
Space("\n"),
|
||||
]),
|
||||
extentions: Separated(
|
||||
values: [
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: "unwrap_newtypes",
|
||||
following: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
),
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: "implicit_some",
|
||||
following: Whitespace([]),
|
||||
),
|
||||
],
|
||||
trailing_comma: false,
|
||||
trailing_ws: Whitespace([]),
|
||||
),
|
||||
after_paren: Whitespace([
|
||||
Space("\n"),
|
||||
]),
|
||||
),
|
||||
),
|
||||
],
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space("\n"),
|
||||
LineComment(" Line Comment\n"),
|
||||
BlockComment(" block "),
|
||||
Space("\n"),
|
||||
BlockComment(" Block Comment /* Nested Block Comment */ "),
|
||||
Space("\n"),
|
||||
]),
|
||||
content: Struct(Struct(
|
||||
ident: None,
|
||||
fields: Separated(
|
||||
values: [
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
content: NamedField(
|
||||
key: "value",
|
||||
after_key: Whitespace([
|
||||
Space(" \n\n "),
|
||||
]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Str(Baked("hello")),
|
||||
),
|
||||
),
|
||||
following: Whitespace([
|
||||
Space(" "),
|
||||
LineComment(" comment\n"),
|
||||
Space(" "),
|
||||
]),
|
||||
),
|
||||
WsWrapped(
|
||||
leading: Whitespace([
|
||||
Space("\n "),
|
||||
]),
|
||||
content: NamedField(
|
||||
key: "something_else",
|
||||
after_key: Whitespace([
|
||||
Space(" "),
|
||||
BlockComment(" "),
|
||||
]),
|
||||
value: WsLead(
|
||||
leading: Whitespace([
|
||||
Space(" "),
|
||||
]),
|
||||
content: Str(Baked("hi")),
|
||||
),
|
||||
),
|
||||
following: Whitespace([
|
||||
Space("\n"),
|
||||
]),
|
||||
),
|
||||
],
|
||||
trailing_comma: false,
|
||||
trailing_ws: Whitespace([]),
|
||||
),
|
||||
)),
|
||||
),
|
||||
trailing_ws: Whitespace([
|
||||
Space("\n"),
|
||||
]),
|
||||
)
|
||||
Reference in new issue
Block a user