Skip to content

Commit 2be58ac

Browse files
committed
Use unstable API feature/keys in added CTParserBuilder funcs
1 parent dbb12c4 commit 2be58ac

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

lrpar/cttests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ crate-type = ["cdylib"]
1212
[build-dependencies]
1313
cfgrammar = { path = "../../cfgrammar" }
1414
lrlex = { path = "../../lrlex" }
15-
lrpar = { path = "../" }
15+
lrpar = { path = "../", features = ["_unstable_api"] }
1616
glob.workspace = true
1717
yaml-rust2.workspace = true
1818
cfg_aliases = "0.2.1"

lrpar/cttests/build.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4949
}
5050

5151
{
52+
use lrpar::unstable_api::UnstableApi;
5253
// In this case we'll be building multiple grammars
5354
//
5455
// 1. Parse multi_start_rule.y into an AST
@@ -64,8 +65,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6465
let modified_ast = valid_ast.clone_and_change_start_rule(bstart_rule).unwrap();
6566
CTLexerBuilder::new()
6667
.lrpar_config(move |ctp| {
67-
ctp.grammar_ast(valid_ast.clone())
68-
.with_grammar_src(grammar_src.clone())
68+
ctp.grammar_ast(valid_ast.clone(), UnstableApi)
69+
.with_grammar_src(grammar_src.clone(), UnstableApi)
6970
.grammar_in_src_dir("multi_start.y")
7071
.unwrap()
7172
.mod_name("ast_unmodified_y")
@@ -85,8 +86,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
8586
.unwrap();
8687
CTLexerBuilder::new()
8788
.lrpar_config(move |ctp| {
88-
ctp.grammar_ast(modified_ast.clone())
89-
.with_grammar_src(grammar_src_clone.clone())
89+
ctp.grammar_ast(modified_ast.clone(), UnstableApi)
90+
.with_grammar_src(grammar_src_clone.clone(), UnstableApi)
9091
.grammar_in_src_dir("multi_start.y")
9192
.unwrap()
9293
.mod_name("ast_modified_y")

lrpar/src/lib/ctbuilder.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ use crate::{
1818
LexerTypes, RTParserBuilder, RecoveryKind,
1919
diagnostics::{DiagnosticFormatter, SpannedDiagnosticFormatter},
2020
};
21+
22+
#[cfg(feature = "_unstable_api")]
23+
use crate::unstable_api::UnstableApi;
24+
2125
use bincode::{Decode, Encode, decode_from_slice, encode_to_vec};
2226
use cfgrammar::{
2327
Location, RIdx, Symbol,
@@ -360,7 +364,8 @@ where
360364

361365
/// If set, specifies that this grammar should be built from a pre-validated AST
362366
/// instead of a `.y`` file. When this is specified, `grammar_path` will not be read.
363-
pub fn grammar_ast(mut self, valid_ast: ASTWithValidityInfo) -> Self {
367+
#[cfg(feature = "_unstable_api")]
368+
pub fn grammar_ast(mut self, valid_ast: ASTWithValidityInfo, _api_key: UnstableApi) -> Self {
364369
self.from_ast = Some(valid_ast);
365370
self
366371
}
@@ -376,7 +381,8 @@ where
376381
self
377382
}
378383

379-
pub fn with_grammar_src(mut self, src: String) -> Self {
384+
#[cfg(feature = "_unstable_api")]
385+
pub fn with_grammar_src(mut self, src: String, _api_key: UnstableApi) -> Self {
380386
self.grammar_src = Some(src);
381387
self
382388
}

0 commit comments

Comments
 (0)