Skip to content

Commit 5561df0

Browse files
committed
Generalize First trait
1 parent 40015bc commit 5561df0

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lang/v0/parser/src/transpiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl TranspileBody<(Option<String>, TokenStream)> for ASTParsec<char> {
116116
}
117117
PAtom(c) => Ok((None, quote!(celma_core::parser::char::a_char(#c)))),
118118
PAtoms(s) => {
119-
let s = s.into_iter().collect::<String>();
119+
let s = s.iter().collect::<String>();
120120
Ok((None, quote!(celma_core::parser::literal::string(#s))))
121121
}
122122
PCode(c) => {

lang/v1/parser/src/first.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ use crate::token::Token::{AllAtom, Atom};
1818
use crate::token::{First, Token};
1919
use celma_lang_ast::syntax::ASTParsec;
2020

21-
impl First<char> for ASTParsec<char> {
22-
fn first(&self) -> Vec<Token<char>> {
21+
impl<E> First<E> for ASTParsec<E>
22+
where
23+
E: Copy,
24+
{
25+
fn first(&self) -> Vec<Token<E>> {
2326
match self {
2427
ASTParsec::PIdent(_) => vec![AllAtom],
2528
ASTParsec::PAtom(c) => vec![Atom(*c)],

lang/v1/parser/tests/first_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod tests {
2222

2323
#[test]
2424
fn it_compute_first_for_ident() {
25-
assert_eq!(vec![AllAtom], PIdent(String::from("test")).first());
25+
assert_eq!(vec![AllAtom::<char>], PIdent(String::from("test")).first());
2626
}
2727

2828
#[test]

0 commit comments

Comments
 (0)