grammar Tnql include Dates include Diagnosis include EBaseRecords include BatchTypes include Provider include RegistrationStatus include Registry include Staging include Treatment include TumourType include Patient include VitalStatus include Age # The root grammar rule query quantity:record_count? pre:preconditions* tumours_keyword post:additional_conditions* end rule word_break !(!(' '/',') .) end rule space ' '+ end rule number [0-9]+ end rule record_count all_keyword / 'first' space number end rule all_keyword 'all' word_break end rule tumours_keyword space 'tumours' word_break end rule preconditions registration_status / registry / behaviour / stage / tumour_type end rule additional_conditions diagnosis / treatment / with_clause / for_patients_clause end end