MCPcopy Create free account
hub / github.com/apache/fory / parse_ref_options

Method parse_ref_options

compiler/fory_compiler/frontend/fdl/parser.py:773–811  ·  view source on GitHub ↗

Parse ref keyword options such as ref(weak=true, thread_safe=false).

(self, name: str)

Source from the content-addressed store, hash-verified

771 return options
772
773 def parse_ref_options(self, name: str) -> dict:
774 """Parse ref keyword options such as ref(weak=true, thread_safe=false)."""
775 if not self.check(TokenType.LPAREN):
776 return {}
777 self.consume(TokenType.LPAREN, "Expected '(' after ref")
778 options = {}
779 while True:
780 name_token = self.current()
781 if self.check(TokenType.IDENT):
782 self.advance()
783 option_name = name_token.value
784 elif self.check(TokenType.WEAK):
785 self.advance()
786 option_name = "weak"
787 else:
788 raise self.error(
789 f"Expected ref option name, got {self.current().type.name}"
790 )
791
792 self.consume(TokenType.EQUALS, "Expected '=' after ref option name")
793 option_value = self.parse_option_value()
794 canonical = REF_OPTION_ALIASES.get(option_name, option_name)
795 options[canonical] = option_value
796
797 if option_name not in KNOWN_REF_OPTIONS:
798 warnings.warn(
799 f"Line {name_token.line}: ignoring unknown ref option '{option_name}' on {name}",
800 stacklevel=2,
801 )
802
803 if self.check(TokenType.COMMA):
804 self.advance()
805 elif self.check(TokenType.RPAREN):
806 break
807 else:
808 raise self.error("Expected ',' or ')' in ref options")
809
810 self.consume(TokenType.RPAREN, "Expected ')' after ref options")
811 return options
812
813 def merge_ref_options(
814 self,

Callers 3

parse_fieldMethod · 0.95
parse_list_typeMethod · 0.95
parse_map_typeMethod · 0.95

Calls 8

checkMethod · 0.95
consumeMethod · 0.95
currentMethod · 0.95
advanceMethod · 0.95
errorMethod · 0.95
parse_option_valueMethod · 0.95
getMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected