Skip to content

Commit f93e023

Browse files
committed
Minor refactoring
1 parent e42a7df commit f93e023

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

lang/v0/macro/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
1716
extern crate proc_macro;
1817

1918
use celma_v0_core::parser::response::Response;

lang/v0/parser/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![warn(clippy::type_complexity)]
21
// #![recursion_limit = "256"]
32

43
pub mod parser;

lang/v1/parser/src/parser.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use celma_v0_core::parser::literal::{delimited_char, delimited_string};
1919

2020
use celma_v0_macro::parsec_rules;
2121
use celma_v1_ast::syntax::ASTParsec::{
22-
PAtom, PAtoms, PBind, PCheck, PChoice, PCode, PEpsilon, PIdent, PMap, PNot, PRepeat,
23-
PSequence, PTry,
22+
PAtom, PAtoms, PBind, PCheck, PChoice, PCode, PEpsilon, PIdent, PMap, PNot, PRepeat, PSequence,
23+
PTry,
2424
};
2525
use celma_v1_ast::syntax::{ASTParsec, ASTParsecRule};
2626

@@ -93,16 +93,16 @@ parsec_rules!(
9393
let skip = (' '|'\t'|'\n'|'\r')* -> {}
9494
let ident:{String} = (skip i=#(alpha (alpha|digit|'_')*) skip) -> { i.into_iter().collect() }
9595

96-
let rkind = (^('<'|'>')+ rkind -> {})
97-
| ('<' rkind '>' rkind -> {})
96+
let kind_content = (^('<'|'>')+ kind_content -> {})
97+
| ('<' kind_content '>' kind_content -> {})
9898
| ()
9999

100-
let rcode = (^('}'|'{')+ rcode -> {})
101-
| ('{' rcode '}' rcode -> {})
100+
let code_content = (^('}'|'{')+ code_content -> {})
101+
| ('{' code_content '}' code_content -> {})
102102
| ()
103103

104-
let kind:{String} = (skip '<' c=#rkind '>' skip) -> { c.into_iter().collect() }
105-
let code:{String} = (skip '{' c=#rcode '}' skip) -> { c.into_iter().collect() }
104+
let kind:{String} = (skip '<' c=#kind_content '>' skip) -> { c.into_iter().collect() }
105+
let code:{String} = (skip '{' c=#code_content '}' skip) -> { c.into_iter().collect() }
106106

107107
let rules:{Vec<ASTParsecRule<char>>} = rule*
108108
let rule:{ASTParsecRule<char>} = (
@@ -117,7 +117,7 @@ parsec_rules!(
117117
let additional:{(bool,ASTParsec<char>)} = (skip c='|'? skip p=parsec) -> { (c.is_some(), p) }
118118

119119
let atom:{ASTParsec<char>} = (
120-
skip o=('^'|'!'|'#'|'/')? skip p=(atom_block|atom_ident|atom_char|atom_string|atom_code) skip
120+
skip o=('^'|'!'|'#')? skip p=(atom_block|atom_ident|atom_char|atom_string|atom_code) skip
121121
) -> { mk_atom(o, p) }
122122

123123
let atom_block:{ASTParsec<char>} = ('(' p=parsec? ')') -> { p.unwrap_or_else(PEpsilon) }

lang/v1/parser/tests/parser_tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod parser_tests {
2020
use celma_v0_core::stream::char_stream::CharStream;
2121
use celma_v0_core::stream::specs::Len;
2222
use celma_v1::parser::{
23-
atom_char, atom_code, atom_ident, atom_string, code, kind, parsec, rcode, rule,
23+
atom_char, atom_code, atom_ident, atom_string, code, code_content, kind, parsec, rule,
2424
};
2525
use celma_v1_ast::syntax::ASTParsec::{
2626
PAtom, PAtoms, PBind, PCheck, PChoice, PCode, PEpsilon, PIdent, PNot, PRepeat, PSequence,
@@ -77,22 +77,22 @@ mod parser_tests {
7777
}
7878

7979
#[test]
80-
fn should_parse_ident_empty_rcode() {
81-
let response = rcode().parse(CharStream::new("}"));
80+
fn should_parse_ident_empty_code_content() {
81+
let response = code_content().parse(CharStream::new("}"));
8282

8383
assert_eq!(response.fold(|_, s, _| s.len() == 1, |_, _| false), true);
8484
}
8585

8686
#[test]
87-
fn should_parse_ident_body_with_block_rcode() {
88-
let response = rcode().parse(CharStream::new("tutu { titi } toto }"));
87+
fn should_parse_ident_body_with_block_code_content() {
88+
let response = code_content().parse(CharStream::new("tutu { titi } toto }"));
8989

9090
assert_eq!(response.fold(|_, s, _| s.len() == 1, |_, _| false), true);
9191
}
9292

9393
#[test]
94-
fn should_parse_ident_body_with_block_unbalanced_rcode() {
95-
let response = rcode().parse(CharStream::new("{ titi"));
94+
fn should_parse_ident_body_with_block_unbalanced_code_content() {
95+
let response = code_content().parse(CharStream::new("{ titi"));
9696

9797
assert_eq!(response.fold(|_, _, _| false, |_, _| true), true);
9898
}

0 commit comments

Comments
 (0)