forked from finos/morphir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start of an implementation of an elm parser in rust
- Loading branch information
1 parent
f3978d0
commit 5d6388a
Showing
8 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "morphir-elm-compiler-rs" | ||
version.workspace = true | ||
description = "Morphir runtime" | ||
homepage.workspace = true | ||
keywords = ["morphir", "finos"] | ||
authors.workspace = true | ||
license.workspace = true | ||
edition.workspace = true | ||
|
||
[badges] | ||
maintnance = { status = "actively-developer" } | ||
|
||
[[bin]] | ||
name = "morphir-elmc" | ||
path = "src/main.rs" | ||
|
||
[lib] | ||
name = "morphir_elm_compiler_rs" | ||
path = "src/lib.rs" | ||
|
||
[features] | ||
|
||
[dependencies] | ||
tokio.workspace = true | ||
pest.workspace = true | ||
pest_derive.workspace = true | ||
|
||
[build-dependencies] | ||
deno_core.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
language: rust |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use pest_derive::Parser; | ||
|
||
#[derive(Parser)] | ||
#[grammar = "elm.pest"] | ||
pub struct ElmParser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//! Parsing rules for the Elm programming language. | ||
|
||
exposing_clause = { "exposing" ~ WHITE_SPACE ~ "(..)" } | ||
// TODO: Relax the casing in parsing and produce an error about improper casing in a later stage | ||
module_path_part = { (ASCII_ALPHA_UPPER ~ (ASCII_ALPHA | ASCII_DIGIT)*) } | ||
module_statement = { "module" ~ WHITE_SPACE ~ module_path ~ WHITE_SPACE ~ (exposing_clause) } | ||
module_path = { module_path_part ~ ("." ~ module_path)* } | ||
statement = { module_statement ~ trivia* } | ||
file = { SOI ~ statement ~ EOI } | ||
INLINE_COMMENT = { "--" ~ (!NEWLINE ~ ANY)* ~ NEWLINE } | ||
COMMENT = { INLINE_COMMENT } | ||
trivia = { WHITE_SPACE | COMMENT } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod compiler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pub(crate) mod compiler; | ||
|
||
use crate::compiler::{ElmParser, Rule}; | ||
use pest::Parser; | ||
|
||
fn main() { | ||
let file_contents: &'static str = r#"module Com.Example.Main exposing (..) | ||
-- This is a comment | ||
-- This is also a comment | ||
"#; | ||
let successful_parse = ElmParser::parse(Rule::file, &file_contents); | ||
println!("{:?}", successful_parse); | ||
} |