MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / read_raw_script

Method read_raw_script

aiscript-lexer/src/lib.rs:731–765  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

729
730impl Lexer<'_> {
731 fn read_raw_script(&mut self) -> Result<String, String> {
732 let mut script = String::new();
733 let mut brace_count = 1;
734
735 while let Some((_, ch)) = self.iter.peek() {
736 match ch {
737 '{' => {
738 brace_count += 1;
739 script.push('{');
740 }
741 '}' => {
742 brace_count -= 1;
743 if brace_count == 0 {
744 break;
745 } else {
746 script.push('}');
747 }
748 }
749 '\n' => {
750 script.push('\n');
751 self.line += 1;
752 }
753 ch => {
754 script.push(*ch);
755 }
756 }
757 self.advance();
758 }
759
760 if brace_count > 0 {
761 return Err("Unclosed script block".to_string());
762 }
763
764 Ok(script.trim().to_owned())
765 }
766}
767
768impl<'a> Iterator for Lexer<'a> {

Callers 1

parse_endpointMethod · 0.80

Calls 4

replaceFunction · 0.85
pushMethod · 0.80
advanceMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected