-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(topic): Split out a dedicated lexing section
- Loading branch information
Showing
4 changed files
with
28 additions
and
14 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,19 +1,6 @@ | ||
//! # Arithmetic | ||
//! | ||
//! ## Direct evaluation | ||
//! | ||
//! This parses arithmetic expressions and directly evaluates them. | ||
//! ```rust | ||
#![doc = include_str!("../../examples/arithmetic/parser.rs")] | ||
//! ``` | ||
//! | ||
//! ## Parse to AST | ||
//! | ||
//! ```rust | ||
#![doc = include_str!("../../examples/arithmetic/parser_ast.rs")] | ||
//! ``` | ||
//! | ||
//! ## Parse to Tokens then AST | ||
//! | ||
//! ```rust | ||
#![doc = include_str!("../../examples/arithmetic/parser_lexer.rs")] | ||
//! ``` |
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,23 @@ | ||
//! # Lexing and Parsing | ||
//! | ||
//! ## Parse to AST | ||
//! | ||
//! The simplest way to write a parser is to parse directly to the AST. | ||
//! | ||
//! Example: | ||
//! ```rust | ||
#![doc = include_str!("../../examples/arithmetic/parser_ast.rs")] | ||
//! ``` | ||
//! | ||
//! ## Lexing | ||
//! | ||
//! However, there are times when you may want to separate lexing from parsing. | ||
//! Winnow provides [`TokenSlice`] to simplify this. | ||
//! | ||
//! Example: | ||
//! ```rust | ||
#![doc = include_str!("../../examples/arithmetic/parser_lexer.rs")] | ||
//! ``` | ||
#![allow(unused_imports)] | ||
use crate::stream::TokenSlice; |
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