Skip to content

Commit 0f93c78

Browse files
committed
feat: test all targets
1 parent 648da4a commit 0f93c78

File tree

6 files changed

+40
-24
lines changed

6 files changed

+40
-24
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ SPDX-License-Identifier: GPL-3.0-only
4747

4848
</p>
4949

50+
Santiago provides you:
51+
52+
- A library for defining any
53+
[context-free grammar](https://en.wikipedia.org/wiki/Context-free_grammar).
54+
- A [Lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) module.
55+
- And facilities for building interpreters or compilers of the language.
56+
57+
With Santiago you have everything that is needed
58+
to build your own programming language!
59+
5060
## Features
5161

5262
- ✔️ **Fast** 🦀

buildkite.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ steps:
99
- direnv allow
1010
- eval "$(direnv export bash)"
1111
- echo +++ Check
12-
- cargo check
12+
- cargo check --all-targets
1313

1414
- label: coverage
1515
if: build.branch == "main"
@@ -40,12 +40,12 @@ steps:
4040
- direnv allow
4141
- eval "$(direnv export bash)"
4242
- echo +++ Lint
43-
- cargo clippy
43+
- cargo clippy --all-targets
4444

4545
- label: test
4646
command:
4747
- echo --- Prepare environment
4848
- direnv allow
4949
- eval "$(direnv export bash)"
5050
- echo +++ Test
51-
- cargo test
51+
- cargo test --all-targets

src/lib.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
#![deny(rustdoc::private_intra_doc_links)]
1313
#![deny(rustdoc::private_doc_tests)]
1414
//! Santiago is a lexing and parsing toolkit for Rust.
15-
//! It provides a library for defining any
16-
//! [context-free grammar](https://en.wikipedia.org/wiki/Context-free_grammar),
17-
//! a [lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) module,
18-
//! and facilities for building evaluators of the language.
15+
//! It provides you:
16+
//! - A library for defining any
17+
//! [context-free grammar](https://en.wikipedia.org/wiki/Context-free_grammar),
18+
//! - A [Lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) module,
19+
//! - And facilities for building interpreters or compilers of the language.
1920
//!
20-
//! With Santiago, you have everything you need to build your own programming
21-
//! language, and a compiler or interpreter for it.
21+
//! With Santiago you have everything that is needed
22+
//! to build your own programming language!
2223
//!
23-
//! Santiago aims to be the Rust alternative to
24+
//! We are the Rust alternative to
2425
//! [GNU Bison](https://en.wikipedia.org/wiki/GNU_Bison),
2526
//! [Yacc](https://en.wikipedia.org/wiki/Yacc) and
2627
//! [Flex](https://en.wikipedia.org/wiki/Flex_(lexical_analyser_generator)).
@@ -118,7 +119,7 @@
118119
//! let parse_trees = santiago::parser::parse(&grammar, &lexemes).unwrap();
119120
//! ```
120121
//!
121-
//! And voilà!
122+
//! Which looks like:
122123
//! ```text
123124
#![doc = include_str!("../tests/ambiguous_integer_addition/cases/addition/parse_trees")]
124125
//! ```
@@ -162,15 +163,19 @@
162163
#![doc = include_str!("../tests/integer_addition/cases/addition/parse_trees")]
163164
//! ```
164165
//!
165-
//! All we are missing now is evaluating the addition,
166-
//! for this let's modify the grammar
166+
//! All we are missing now is evaluating the addition.
167+
//! For this let's modify the grammar
167168
//! so that each time a rule matches
168-
//! we produce an amenable data-structure:
169+
//! we produce an amenable data-structure
170+
//! that can be turned into an Abstract Syntax Tree:
169171
//! ```rust
170172
#![doc = include_str!("../tests/integer_addition_with_value/grammar.rs")]
171173
//! ```
172174
//!
173-
//! We just need to call Santiago's builtin-function `as_abstract_syntax_tree()`.
175+
//! Now, the next time we parse,
176+
//! we can transform our Parse Tree into
177+
//! an Abstract Syntax Tree
178+
//! by calling Santiago's builtin-function `as_abstract_syntax_tree()`.
174179
//! ```rust
175180
//! # mod m {
176181
//! # include!("../tests/integer_addition_with_value/eval.rs");
@@ -190,7 +195,7 @@
190195
//! let ast = parse_tree.as_abstract_syntax_tree();
191196
//!
192197
//! assert_eq!(
193-
//! value,
198+
//! ast,
194199
//! BinaryOperation(vec![
195200
//! BinaryOperation(vec![
196201
//! Int(10),
@@ -232,7 +237,7 @@
232237
//! #
233238
//! let ast = parse_tree.as_abstract_syntax_tree();
234239
//!
235-
//! assert_eq!(eval(&value), 60);
240+
//! assert_eq!(eval(&ast), 60);
236241
//! ```
237242
//!
238243
//! How nice is that?
@@ -439,7 +444,7 @@
439444
//!
440445
//! let ast = parse_tree.as_abstract_syntax_tree();
441446
//!
442-
//! assert_eq!(eval(&value), -6);
447+
//! assert_eq!(eval(&ast), -6);
443448
//! ```
444449
//!
445450
//! ## JavaScript string interpolations

src/parser/tree.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use std::collections::HashMap;
1414
use std::collections::LinkedList;
1515
use std::rc::Rc;
1616

17-
/// Representation of an AST.
17+
/// Representation of a Parse Tree,
18+
/// than can be turned into an Abstract Syntax Tree.
1819
pub enum Tree<AST> {
1920
/// Leaf nodes of the tree, containing a [Lexeme].
2021
Leaf(Lexeme),

tests/calculator_with_value/grammar.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ pub fn grammar() -> Grammar<AST> {
1717
"expr" => rules "int";
1818

1919
"bin_op" => rules "expr" "add" "expr" =>
20-
|values| AST::BinaryOperation(values);
20+
AST::BinaryOperation;
2121
"bin_op" => rules "expr" "subtract" "expr" =>
22-
|values| AST::BinaryOperation(values);
22+
AST::BinaryOperation;
2323
"bin_op" => rules "expr" "multiply" "expr" =>
24-
|values| AST::BinaryOperation(values);
24+
AST::BinaryOperation;
2525
"bin_op" => rules "expr" "divide" "expr" =>
26-
|values| AST::BinaryOperation(values);
26+
AST::BinaryOperation;
2727

2828
"add" => lexemes "+" =>
2929
|_| AST::OperatorAdd;

tests/integer_addition_with_value/grammar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub enum AST {
1414
pub fn grammar() -> Grammar<AST> {
1515
santiago::grammar!(
1616
"sum" => rules "sum" "plus" "sum" =>
17-
|values| AST::BinaryOperation(values);
17+
AST::BinaryOperation;
1818

1919
"sum" => lexemes "INT" => |lexemes| {
2020
// &str to isize conversion

0 commit comments

Comments
 (0)