Git Product home page Git Product logo

poc-tree-sitter-nginx's Introduction

POC nginx configuration parser

Currently, it can parse configuration from nginx config example

Example

# copy from https://www.nginx.com/resources/wiki/start/topics/examples/full/
user       www www;  ## Default: nobody

http {
  include    conf/mime.types;

  server { # simple load balancing
    listen          80;
    server_name     big.server.com;

    location / {
      proxy_pass      http://big_server_com;
    }
  }
}

will produce

(source_file [0, 0] - [14, 1]
  (comment [0, 0] - [0, 76])
  (statement [1, 0] - [1, 19]
    (call_stmt [1, 0] - [1, 19]
      (identifier [1, 0] - [1, 4])
      (literal [1, 11] - [1, 14])
      (literal [1, 15] - [1, 18])))
  (comment [1, 21] - [1, 39])
  (block_definition [3, 0] - [14, 1]
    (identifier [3, 0] - [3, 4])
    consequence: (statement [4, 2] - [4, 29]
      (call_stmt [4, 2] - [4, 29]
        (identifier [4, 2] - [4, 9])
        (literal [4, 13] - [4, 28])))
    consequence: (block_definition [6, 2] - [13, 3]
      (identifier [6, 2] - [6, 8])
      consequence: (comment [6, 11] - [6, 34])
      consequence: (statement [7, 4] - [7, 23]
        (call_stmt [7, 4] - [7, 23]
          (identifier [7, 4] - [7, 10])
          (literal [7, 20] - [7, 22])))
      consequence: (statement [8, 4] - [8, 35]
        (call_stmt [8, 4] - [8, 35]
          (identifier [8, 4] - [8, 15])
          (literal [8, 20] - [8, 34])))
      consequence: (block_definition [10, 4] - [12, 5]
        (identifier [10, 4] - [10, 12])
        args: (literal [10, 13] - [10, 14])
        consequence: (statement [11, 6] - [11, 44]
          (call_stmt [11, 6] - [11, 44]
            (identifier [11, 6] - [11, 16])
            (literal [11, 22] - [11, 43])))))))

Acknowledgments

poc-tree-sitter-nginx's People

Contributors

wireless4024 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.