Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grammar railroad diagram #6

Open
mingodad opened this issue Mar 25, 2024 · 0 comments
Open

Grammar railroad diagram #6

mingodad opened this issue Mar 25, 2024 · 0 comments

Comments

@mingodad
Copy link

I've just added this project grammar to https://mingodad.github.io/parsertl-playground/playground/ an Yacc/Lex compatible online editor/tester (select Mimosa http request parser from Examples then click Parse to see a parse tree for the content in Input source).

Notice that I've replaced right recursion by left recursion in some rules.

And here is an EBNF to generate a nice navigable railroad diagram:

//
// EBNF to be viewd at https://www.bottlecaps.de/rr/ui
//
// Copy and paste this at https://www.bottlecaps.de/rr/ui in the 'Edit Grammar' tab
// then click the 'View Diagram' tab.
//

request::=
	  method LOCATION PROTO_MAJOR PROTO_MINOR kvs

method::=
	  HEAD
	| GET
	| POST
	| PUT
	| DELETE
	| TRACE
	| OPTIONS
	| CONNECT
	| PATCH
	| PROPFIND
	| PROPPATCH
	| MKCOL
	| COPY
	| MOVE
	| LOCK
	| UNLOCK
	| MIMOSA_SYMLINK

kvs::=
	  kvs kv
	| /*%empty*/

kv::=
	  KEY_ACCEPT_ENCODING accept_encodings
	| KEY_CONNECTION VALUE_CONNECTION
	| KEY_COOKIE cookies
	| KEY_CONTENT_LENGTH VAL64
	| KEY_CONTENT_TYPE VALUE
	| KEY_HOST HOST PORT
	| KEY_HOST HOST
	| KEY_REFERRER VALUE
	| KEY_USER_AGENT VALUE
	| KEY_IF_MODIFIED_SINCE VALUE
	| KEY_DESTINATION VALUE
	| KEY_CONTENT_RANGE RANGE_UNIT RANGE_START RANGE_END RANGE_LENGTH
	| KEY_RANGE RANGE_UNIT '=' byte_range_set
	| KEY VALUE

accept_encodings::=
	  /*%empty*/
	| accept_encodings COMPRESS
	| accept_encodings IDENTITY
	| accept_encodings DEFLATE
	| accept_encodings GZIP
	| accept_encodings ZSTD
	| accept_encodings BR
	| accept_encodings SDCH

cookies::=
	  /*%empty*/
	| cookie
	| cookies ';' cookie

cookie::=
	  ATTR
	| ATTR '='
	| ATTR '=' VALUE

byte_range_set::=
	  byte_range
	| byte_range_set ',' byte_range

byte_range::=
	  VAL64 '-' VAL64
	| VAL64 '-'
	| '-' VAL64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant