Skip to content

RFC: Implement language features (Lexer and Parser) #40

@mateusabelli

Description

@mateusabelli

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:

Image Source

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requestedserverThis is related to server code

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions