Skip to content

Source text parsing, lexing, and AST related functionality for Deno

License

Notifications You must be signed in to change notification settings

happysmile12321/deno_ast

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deno_ast

Discord Chat

Source text parsing, lexing, and AST related functionality for Deno.

use deno::ast::MediaType;
use deno::ast::parse_module;
use deno::ast::ParseParams;
use deno::ast::SourceTextInfo;

let source_text = Arc::new("class MyClass {}");
let source_text_info = SourceTextInfo::new(source_text);
let parsed_source = parse_module(ParseParams {
  specifier: "file:///my_file.ts".to_string(),
  media_type: MediaType::TypeScript,
  source: source_text_info,
  capture_tokens: true,
  maybe_syntax: None,
  scope_analysis: false,
}).expect("should parse");

// returns the comments
parsed_source.comments();
// returns the tokens if captured
parsed_source.tokens();
// returns the module (AST)
parsed_source.module();
// returns the `SourceTextInfo`
parsed_source.source();

About

Source text parsing, lexing, and AST related functionality for Deno

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 83.5%
  • TypeScript 16.5%