backyard-lexer

Crates.iobackyard-lexer
lib.rsbackyard-lexer
version
sourcesrc
created_at2024-11-27 12:53:16.748174
updated_at2024-12-12 08:45:32.770797
descriptionGenerating tokens representation of PHP code.
homepage
repositoryhttps://github.com/Alzera/backyard
max_upload_size
id1462978
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Alzera Cita (Alzera)

documentation

README

backyard-lexer

Generating tokens representation of PHP code.

features

  • Parse string to tokens (lex() & lex_eval())

usage

fn main() {
  let arena = bumpalo::Bump::new();
  let code = r#"<?php
  function hello_world($foo) {
    var_dump($foo);
  }"#;

  let parsed = backyard_lexer::lex(&arena, code);
  println!("{:?}", parsed);
}

Resulting this:

Ok([
  Token { token_type: Function, value: "function", line: 2, column: 4, offset: 10 },
  Token { token_type: Identifier, value: "hello_world", line: 2, column: 13, offset: 19 },
  Token { token_type: LeftParenthesis, value: "(", line: 2, column: 24, offset: 30 },
  Token { token_type: Variable, value: "foo", line: 2, column: 25, offset: 31 },
  Token { token_type: RightParenthesis, value: ")", line: 2, column: 29, offset: 35 },
  Token { token_type: LeftCurlyBracket, value: "{", line: 2, column: 31, offset: 37 },
  Token { token_type: Identifier, value: "var_dump", line: 3, column: 6, offset: 45 },
  Token { token_type: LeftParenthesis, value: "(", line: 3, column: 14, offset: 53 },
  Token { token_type: Variable, value: "foo", line: 3, column: 15, offset: 54 },
  Token { token_type: RightParenthesis, value: ")", line: 3, column: 19, offset: 58 },
  Token { token_type: Semicolon, value: ";", line: 3, column: 20, offset: 59 },
  Token { token_type: RightCurlyBracket, value: "}", line: 4, column: 4, offset: 65 }
])

ecosystem

heavily inspired by

license

MIT

Commit count: 158

cargo fmt