text_scanner/ext/
jsonc.rs

1use crate::{ext::CScannerExt, Scanner, ScannerResult};
2
3/// [`Scanner`] extension for scanning [JSON with Comments] tokens.
4///
5/// [JSON with Comments]: https://code.visualstudio.com/docs/languages/json#_json-with-comments
6pub trait JsonCScannerExt<'text>: crate::private::Sealed {
7    fn scan_jsonc_line_comment(&mut self) -> ScannerResult<'text, &'text str>;
8    fn scan_jsonc_block_comment(&mut self) -> ScannerResult<'text, &'text str>;
9}
10
11impl<'text> JsonCScannerExt<'text> for Scanner<'text> {
12    // Reference: https://code.visualstudio.com/docs/languages/json#_json-with-comments
13    #[inline]
14    fn scan_jsonc_line_comment(&mut self) -> ScannerResult<'text, &'text str> {
15        self.scan_c_line_comment()
16    }
17
18    // Reference: https://code.visualstudio.com/docs/languages/json#_json-with-comments
19    #[inline]
20    fn scan_jsonc_block_comment(&mut self) -> ScannerResult<'text, &'text str> {
21        self.scan_c_block_comment()
22    }
23}