diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-08-17 16:25:09 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-08-17 16:25:09 +0200 |
| commit | 3cbca56a7195bb2a7996530d584300d697c11dc8 (patch) | |
| tree | 2a9242442bb79ae4b70895cabeb95b7aff2a4f5d /benches | |
| parent | 8a80503188804d576636265e71f72e9f55a7961a (diff) | |
Parse braced expressions and bracketed calls in headers 🗳
- Refactors the tokenizer to be lazy: It does not emit pre-parsed function tokens, but instead allows it's mode to be changed. The modes are tracked on a stack to allow nested compute/typesetting (pop/push).
- Introduces delimited groups into the parser, which make it easy to parse delimited expressions without handling the delimiters in the parsing code for the group's content. A group is started with `start_group`. When reaching the group's end (matching delimiter) the eat and peek methods will simply return `None` instead of the delimiter, stopping the content parser and bubbling up the call stack until `end_group` is called to clear up the situation.
Diffstat (limited to 'benches')
| -rw-r--r-- | benches/bench_parsing.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/benches/bench_parsing.rs b/benches/bench_parsing.rs index a3a17a84..4a8a7eb2 100644 --- a/benches/bench_parsing.rs +++ b/benches/bench_parsing.rs @@ -1,18 +1,17 @@ use criterion::{criterion_group, criterion_main, Criterion}; use typstc::syntax::parsing::parse; -use typstc::syntax::span::Pos; // 28 not too dense lines. const COMA: &str = include_str!("../tests/coma.typ"); fn parsing_benchmark(c: &mut Criterion) { c.bench_function("parse-coma-28-lines", |b| { - b.iter(|| parse(COMA, Pos::ZERO)) + b.iter(|| parse(COMA)) }); let long = COMA.repeat(100); c.bench_function("parse-coma-2800-lines", |b| { - b.iter(|| parse(&long, Pos::ZERO)) + b.iter(|| parse(&long)) }); } |
