-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Summary
Despite not being a programming language, HTTP exhibits certain language-like characteristics such as attribute value pairs like Content-Type: application/json, keywords like POST or GET, and a structural format. These features make it an excellent candidate for incorporating programming language features like a lexer and parser.
Possible Solution
Note Your comments are appreciated!
One possible approach to implementing HTTP as a minimal language, is by using the ply library.
With it, instead of using regex patterns like this, or file based resources to loop through and pick the corresponding item
pattern = r"\b(?!GET|POST)[A-Z]{3,7}\b"it would be more effective doing something like this:
tokens = [
'CODE',
'METHOD',
'...'
]And let ply build language-like characteristics to help the language server provide its own features like diagnostics, completion and hover docs.
Illustration
The following image provides an example of the structured format of HTTP messages:
