File tree Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 11//! Uiua's abstract syntax tree
22
3- use std:: { collections:: HashMap , fmt, mem:: discriminant} ;
3+ use std:: { collections:: BTreeMap , fmt, mem:: discriminant} ;
44
55use ecow:: EcoString ;
66use serde:: * ;
@@ -311,7 +311,7 @@ pub struct Comments {
311311 /// The normal comment lines
312312 pub lines : Vec < Sp < EcoString > > ,
313313 /// The semantic comments
314- pub semantic : HashMap < SemanticComment , CodeSpan > ,
314+ pub semantic : BTreeMap < SemanticComment , CodeSpan > ,
315315}
316316
317317/// An inline macro
Original file line number Diff line number Diff line change @@ -829,10 +829,10 @@ impl From<SemanticComment> for Token {
829829pub enum SemanticComment {
830830 /// Allow experimental features
831831 Experimental ,
832- /// Prevent the containing function from being inlined
833- NoInline ,
834832 /// Prevent stack traces from going deeper
835833 TrackCaller ,
834+ /// Prevent the containing function from being inlined
835+ NoInline ,
836836 /// Mark that a function should be bound externally
837837 External ,
838838 /// Mark a function as deprecated
Original file line number Diff line number Diff line change 11//! The Uiua parser
22
33use std:: {
4- collections:: HashMap ,
4+ collections:: BTreeMap ,
55 error:: Error ,
66 f64:: consts:: { PI , TAU } ,
77 fmt,
@@ -1746,14 +1746,13 @@ impl Parser<'_> {
17461746 }
17471747 fn comments ( & mut self ) -> Option < Comments > {
17481748 let mut lines = Vec :: new ( ) ;
1749- let mut semantic = HashMap :: new ( ) ;
1749+ let mut semantic = BTreeMap :: new ( ) ;
17501750 loop {
17511751 self . ignore_whitespace ( ) ;
17521752 if let Some ( span) = self . exact ( Comment ) {
17531753 let s = span. as_str ( self . inputs , |s| s. trim_start_matches ( "#" ) . trim ( ) . into ( ) ) ;
17541754 lines. push ( span. sp ( s) ) ;
17551755 } else if let Some ( sem) = self . next_token_map ( Token :: as_semantic_comment) {
1756- lines. push ( sem. span . clone ( ) . sp ( sem. value . to_string ( ) . into ( ) ) ) ;
17571756 semantic. insert ( sem. value , sem. span ) ;
17581757 } else {
17591758 break ;
Original file line number Diff line number Diff line change @@ -381,6 +381,9 @@ impl Spanner {
381381 for line in & comments. lines {
382382 spans. push ( line. span . clone ( ) . sp ( SpanKind :: Comment ) ) ;
383383 }
384+ for span in comments. semantic . values ( ) {
385+ spans. push ( span. clone ( ) . sp ( SpanKind :: Comment ) ) ;
386+ }
384387 }
385388 spans. push ( field. name . span . clone ( ) . sp ( SpanKind :: Ident {
386389 docs : self . binding_docs ( & field. name . span ) ,
You can’t perform that action at this time.
0 commit comments