MCPcopy Create free account
hub / github.com/GPPVM-Project/SkyLC / parse_internal_function

Method parse_internal_function

crates/skyl-parser/src/parser.rs:80–204  ·  view source on GitHub ↗
(&mut self, access: Visibility)

Source from the content-addressed store, hash-verified

78 }
79
80 fn parse_internal_function(&mut self, access: Visibility) -> Result<Statement, ParseError> {
81 let start_token = self.previous();
82 self.eat(
83 TokenKind::Keyword(KeywordKind::Def),
84 CompilationErrorKind::ExpectedToken {
85 expect: "def".into(),
86 found: self.peek().lexeme.clone(),
87 after: None,
88 },
89 )?;
90
91 let function_name = self.eat(
92 TokenKind::Identifier,
93 CompilationErrorKind::ExpectedToken {
94 expect: "identifier".into(),
95 found: self.peek().lexeme.clone(),
96 after: None,
97 },
98 )?;
99
100 self.eat(
101 TokenKind::Punctuation(PunctuationKind::LeftParen),
102 CompilationErrorKind::ExpectedToken {
103 expect: "(".into(),
104 found: self.peek().lexeme.clone(),
105 after: None,
106 },
107 )?;
108
109 let mut params: Vec<FieldDeclaration> = Vec::new();
110
111 let param_name = self.eat(
112 TokenKind::Identifier,
113 CompilationErrorKind::ExpectedConstruction {
114 expect: "'self' param".into(),
115 found: self.peek().lexeme,
116 },
117 )?;
118
119 self.eat(
120 TokenKind::Punctuation(PunctuationKind::Colon),
121 CompilationErrorKind::ExpectedToken {
122 expect: "':'".into(),
123 found: self.peek().lexeme.clone(),
124 after: None,
125 },
126 )?;
127
128 let param_type = self.type_composition()?;
129
130 params.push(FieldDeclaration::new(
131 Visibility::Public,
132 param_name,
133 param_type,
134 ));
135
136 if !self.check(&[TokenKind::Punctuation(PunctuationKind::RightParen)]) {
137 while self.try_eat(&[TokenKind::Punctuation(PunctuationKind::Comma)]) {

Callers 3

declarationMethod · 0.80
parse_pub_accessMethod · 0.80
parse_mod_accessMethod · 0.80

Calls 12

OperatorClass · 0.85
eatMethod · 0.80
cloneMethod · 0.80
type_compositionMethod · 0.80
parse_scopeMethod · 0.80
mergeMethod · 0.80
previousMethod · 0.45
peekMethod · 0.45
pushMethod · 0.45
checkMethod · 0.45
try_eatMethod · 0.45
spanMethod · 0.45

Tested by

no test coverage detected