Function parse_identifier

Source
pub fn parse_identifier(input: &str) -> IResult<&str, String>
Expand description

Parse an identifier according to JSON language specification.

Identifiers in AIM follow standard JSON naming conventions: they must start with a letter, dollar sign or underscore, followed by any combination of letters, digits, and underscores.

Leading underscore identifiers represent an alignable reference for inference output.

§Arguments

  • input - A string slice to parse for an identifier

§Returns

  • IResult<&str, String> - A nom result with remaining input and parsed identifier

§Examples

use aimx::expressions::reference::parse_identifier;
 
assert_eq!(parse_identifier("foo"), Ok(("", "foo".to_string())));
assert_eq!(parse_identifier("_bar123"), Ok(("", "_bar123".to_string())));
assert_eq!(parse_identifier("my_function"), Ok(("", "my_function".to_string())));