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

Method parse_enum_value

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

Parse an enum value: NAME = 0;

(self)

Source from the content-addressed store, hash-verified

449 self.consume(TokenType.SEMI, "Expected ';' after reserved statement")
450
451 def parse_enum_value(self) -> EnumValue:
452 """Parse an enum value: NAME = 0;"""
453 start = self.current()
454 name = self.consume(TokenType.IDENT, "Expected enum value name").value
455 self.consume(TokenType.EQUALS, "Expected '=' after enum value name")
456 value_token = self.consume(TokenType.INT, "Expected integer value")
457 value = int(value_token.value)
458 self.consume(TokenType.SEMI, "Expected ';' after enum value")
459
460 return EnumValue(
461 name=name,
462 value=value,
463 line=start.line,
464 column=start.column,
465 location=self.make_location(start),
466 )
467
468 def parse_message(self) -> Message:
469 """Parse a message: message Dog [id=102] { ... }

Callers 1

parse_enumMethod · 0.95

Calls 4

currentMethod · 0.95
consumeMethod · 0.95
make_locationMethod · 0.95
EnumValueClass · 0.90

Tested by

no test coverage detected