nginx_discovery/parser/mod.rs
1//! NGINX configuration parser
2
3mod lexer;
4mod parse;
5mod token;
6
7pub use lexer::Lexer;
8pub use parse::Parser;
9pub use token::{Token, TokenKind};
10
11use crate::ast::Config;
12use crate::error::Result;
13
14/// Parse NGINX configuration from text
15///
16/// This is the main entry point for parsing.
17///
18/// # Errors
19///
20/// Returns an error if:
21/// - The input contains syntax errors
22/// - Unexpected tokens are encountered
23/// - The configuration structure is invalid
24///
25/// # Examples
26///
27/// ```
28/// use nginx_discovery::parse;
29///
30/// let config = "user nginx;";
31/// let result = parse(config).unwrap();
32/// assert_eq!(result.directives.len(), 1);
33/// ```
34pub fn parse(input: &str) -> Result<Config> {
35 let mut parser = Parser::new(input)?;
36 parser.parse()
37}