-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07c895e
commit cb9ab7c
Showing
5 changed files
with
55 additions
and
0 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
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,22 @@ | ||
use rustemo::{rustemo_mod, Parser}; | ||
use rustemo_compiler::output_cmp; | ||
|
||
rustemo_mod!(most_specific, "/src/glr/lexical_ambiguity"); | ||
rustemo_mod!(most_specific_actions, "/src/glr/lexical_ambiguity"); | ||
|
||
use self::most_specific::MostSpecificParser; | ||
|
||
#[test] | ||
fn glr_lexical_ambiguity_most_specific() { | ||
let forest = MostSpecificParser::new().parse("s a 42.42").unwrap(); | ||
assert_eq!(forest.solutions(), 2); | ||
|
||
let mut trees = String::new(); | ||
for tree in &forest { | ||
trees.push_str(&format!("{tree:#?}\n\n")); | ||
} | ||
output_cmp!( | ||
"src/glr/lexical_ambiguity/most_specific.ast", | ||
format!("{trees}") | ||
); | ||
} |
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,15 @@ | ||
[ | ||
"s", | ||
[ | ||
"a 42.42", | ||
], | ||
] | ||
|
||
[ | ||
"s", | ||
[ | ||
"a", | ||
"42.42", | ||
], | ||
] | ||
|
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,13 @@ | ||
S: 's' A; | ||
// These two alternative overlaps at the lexical level but the first one wins as | ||
// it uses a string match which is more specific than regex match. | ||
// | ||
// This stategy is by default on but can be turned off in the settings. | ||
A: 'a' Float | Complex; | ||
|
||
|
||
terminals | ||
Ta: 'a'; | ||
Ts: 's'; | ||
Float: /\d+\.\d+/; | ||
Complex: /a \d+\.\d+/; |
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ mod build; | |
mod errors; | ||
mod evaluate; | ||
mod forest; | ||
mod lexical_ambiguity; | ||
mod special; |