def visitParserRuleSpec(self, ctx: Parser.ParserRuleSpecContext): content: ParserRule.RuleContent = self.visit(ctx.ruleBlock()) doc_info = load_docs(self._model, ctx.docs) rule = ParserRule( name=ctx.name.text, display_name=doc_info['name'] or None, model=self._model, position=Position(self._model.get_path(), ctx.start.line + self._model.get_offset()), content=content, is_doxygen_nodoc=doc_info['is_doxygen_nodoc'], is_doxygen_inline=doc_info['is_doxygen_inline'], is_doxygen_no_diagram=doc_info['is_doxygen_no_diagram'], importance=doc_info['importance'], documentation=doc_info['documentation'], section=self._current_section, ) self._model.set_parser_rule(rule.name, rule)
def visitSetElementLit(self, ctx: Parser.SetElementLitContext): return ParserRule.Reference(model=self._model, name=ctx.value.text)
def visitNotBlock(self, ctx: Parser.NotBlockContext): return ParserRule.Negation(child=self.visit(ctx.value))
def visitNotElement(self, ctx: Parser.NotElementContext): return ParserRule.Negation(child=self.visit(ctx.value))
def visitRuleref(self, ctx: Parser.RulerefContext): return ParserRule.Reference(model=self._model, name=ctx.value.text)
def visitTerminalLit(self, ctx: Parser.TerminalLitContext): return ParserRule.Reference(model=self._model, name=ctx.value.text)
def visitParserInlineDoc(self, ctx: Parser.ParserInlineDocContext): docs = load_docs(self._model, [ctx.value], False)['documentation'] return ParserRule.Doc(value='\n'.join(d[1] for d in docs))