Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-opus-4-20250514-thinking-16k· AnthropicHugging Face LMArena Human Preference 140K

Write me a gbnf grammar. When a paragraph starts with " it should end at the next…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-flash-lite-preview-06-17-thinking’s answer.
  1. User

    Write me a gbnf grammar. When a paragraph starts with " it should end at the next occurance of ", () are not allowed. When a paragraph starts with ( it should end at the next occurance of ), " is not allowed. Should a paragraph start without " or (, it should not be allowed to contain " and (). Paragraph is any text that ends with either new line or <|end▁of▁sentence|> So this is an example text that's allowed: Hi there! <3

    "Hello! <>" (silence is deep) And this is an example of text that's not allowed: "Hi there" He said. "Hello" (she answered) Nothing ever happens(silence.)

  2. Claude Assistant

    Here's a GBNF grammar that implements your paragraph rules:

    root ::= paragraph*
    
    paragraph ::= quoted-paragraph | paren-paragraph | regular-paragraph
    
    quoted-paragraph ::= "\"" quoted-content "\"" paragraph-end
    paren-paragraph ::= "(" paren-content ")" paragraph-end  
    regular-paragraph ::= regular-content paragraph-end
    
    paragraph-end ::= "\n" | "<|end▁of▁sentence|>"
    
    # Content rules for each paragraph type
    quoted-content ::= quoted-char*
    paren-content ::= paren-char*
    regular-content ::= regular-char+
    
    # Character definitions
    quoted-char ::= [^"()\n<] | "<" [^|]
    paren-char ::= [^"\n<] | "<" [^|]
    regular-char ::= [^"()\n<] | "<" [^|]
    

    This grammar ensures:

    • Quoted paragraphs start with ", end with ", and cannot contain () inside
    • Parenthetical paragraphs start with (, end with ), and cannot contain " inside
    • Regular paragraphs cannot contain any ", (, or )
    • All paragraphs end with either a newline or <|end▁of▁sentence|>

    The character classes handle the special case of < which is allowed unless it's the start of the end-of-sentence marker. This prevents false matches while still allowing characters like <3 in your example.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.