Parse property access token: object.property
(tokens: &[Token])
| 2338 | |
| 2339 | /// Parse property access token: object.property |
| 2340 | fn property_access_token(tokens: &[Token]) -> IResult<&[Token], PropertyAccess> { |
| 2341 | if let Some(Token::PropertyAccess(s)) = tokens.first() { |
| 2342 | // Parse the property access string "object.property" |
| 2343 | let parts: Vec<&str> = s.split('.').collect(); |
| 2344 | if parts.len() == 2 { |
| 2345 | Ok(( |
| 2346 | &tokens[1..], |
| 2347 | PropertyAccess { |
| 2348 | object: parts[0].to_string(), |
| 2349 | property: parts[1].to_string(), |
| 2350 | location: Location::default(), |
| 2351 | }, |
| 2352 | )) |
| 2353 | } else { |
| 2354 | Err(nom::Err::Error(nom::error::Error::new( |
| 2355 | tokens, |
| 2356 | nom::error::ErrorKind::Tag, |
| 2357 | ))) |
| 2358 | } |
| 2359 | } else { |
| 2360 | Err(nom::Err::Error(nom::error::Error::new( |
| 2361 | tokens, |
| 2362 | nom::error::ErrorKind::Tag, |
| 2363 | ))) |
| 2364 | } |
| 2365 | } |
| 2366 | |
| 2367 | /// Parse identifier (does NOT accept string literals - use identifier_or_quoted for that) |
| 2368 | fn identifier(tokens: &[Token]) -> IResult<&[Token], String> { |