[−][src]Crate ressa
RESSA (Rusty ECMAScript Syntax Analyzer) A library for parsing js files
The main interface for this library would be
the Parser iterator. A parser is constructed
either via the ::new() function or a Builder.
As part of the constructor, you have to provide
the js you want to parse as an &str.
Once constructed the parser will return a
ProgramPart for each iteration.
A very simple example might look like this
extern crate ressa; use ressa::{ Parser, node::*, }; fn main() { let js = "function helloWorld() { alert('Hello world'); }"; let p = Parser::new(&js).unwrap(); let f = ProgramPart::decl( Declaration::Function( Function { id: Some("helloWorld".to_string()), params: vec![], body: vec![ ProgramPart::Statement( Statement::Expr( Expression::call(Expression::ident("alert"), vec![Expression::string("'Hello world'")]) ) ) ], generator: false, is_async: false, } ) ); for part in p { assert_eq!(part.unwrap(), f); } }
checkout the examples folders for slightly larger
examples.
Modules
| node |
Structs
| Builder | This is used to create a |
| Line | The start/end index of a line |
| Parser | This is the primary interface that you would interact with.
There are two main ways to use it, the first is to utilize
the |
Enums
| Error |
Traits
| CommentHandler | A comment handler will allow you to specify behavior about what to do with comments officially comments are supposed to operate the same as whitespace so the default behavior would be to throw away any comments found |