This repository was archived by the owner on Sep 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ fn main() {
1515 emit_tests ( & mut out, "isle_examples/link" , "run_link" ) ;
1616 emit_tests ( & mut out, "isle_examples/run" , "run_run" ) ;
1717
18+ emit_tests ( & mut out, "isle_examples/pass" , "run_print" ) ;
19+ emit_tests ( & mut out, "isle_examples/link" , "run_print" ) ;
20+ emit_tests ( & mut out, "isle_examples/run" , "run_print" ) ;
21+
1822 let output = out_dir. join ( "isle_tests.rs" ) ;
1923 std:: fs:: write ( output, out) . unwrap ( ) ;
2024}
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ pub mod lexer;
2828mod log;
2929pub mod overlap;
3030pub mod parser;
31+ pub mod printer;
3132pub mod sema;
3233pub mod serialize;
3334pub mod stablemapset;
Original file line number Diff line number Diff line change @@ -12,12 +12,20 @@ pub fn parse(lexer: Lexer) -> Result<Vec<Def>> {
1212 parser. parse_defs ( )
1313}
1414
15+ /// Parse without positional information. Provided mainly to support testing, to
16+ /// enable equality testing on structure alone.
17+ pub fn parse_without_pos ( lexer : Lexer ) -> Result < Vec < Def > > {
18+ let parser = Parser :: new_without_pos_tracking ( lexer) ;
19+ parser. parse_defs ( )
20+ }
21+
1522/// The ISLE parser.
1623///
1724/// Takes in a lexer and creates an AST.
1825#[ derive( Clone , Debug ) ]
1926struct Parser < ' a > {
2027 lexer : Lexer < ' a > ,
28+ disable_pos : bool ,
2129}
2230
2331/// Used during parsing a `(rule ...)` to encapsulate some form that
@@ -31,7 +39,17 @@ enum IfLetOrExpr {
3139impl < ' a > Parser < ' a > {
3240 /// Construct a new parser from the given lexer.
3341 pub fn new ( lexer : Lexer < ' a > ) -> Parser < ' a > {
34- Parser { lexer }
42+ Parser {
43+ lexer,
44+ disable_pos : false ,
45+ }
46+ }
47+
48+ fn new_without_pos_tracking ( lexer : Lexer < ' a > ) -> Parser < ' a > {
49+ Parser {
50+ lexer,
51+ disable_pos : true ,
52+ }
3553 }
3654
3755 fn error ( & self , pos : Pos , msg : String ) -> Error {
@@ -72,9 +90,13 @@ impl<'a> Parser<'a> {
7290 }
7391
7492 fn pos ( & self ) -> Pos {
75- self . lexer
76- . peek ( )
77- . map_or_else ( || self . lexer . pos ( ) , |( pos, _) | * pos)
93+ if !self . disable_pos {
94+ self . lexer
95+ . peek ( )
96+ . map_or_else ( || self . lexer . pos ( ) , |( pos, _) | * pos)
97+ } else {
98+ Pos :: default ( )
99+ }
78100 }
79101
80102 fn is_lparen ( & self ) -> bool {
You can’t perform that action at this time.
0 commit comments