//TODO @mark: tests for FQNs
/// Parse a qualified name, which is (identifier + period)* + identifier
///
/// Note that field access for a record has the same structure, so context is important:
///
/// * Declarations of modules, records or functions should be simple (without periods)
/// * Names of imports are fully qualified (usually, but not always, containing periods)
/// * Uses of records or functions can either use fully qualified name or simple name.


Note that field access for a record has the same structure, so context is important.

Declarations of modules, records or functions should be simple (without periods)
Names of imports are fully qualified (usually, but not always, containing periods)
Uses of records or functions can either use fully qualified name or simple name.
Note that field access for a record has the same structure so context is important . Declarations of modules records or functions should be simple ( without periods ) Names of imports are fully qualified ( usually but not always containing periods ) Uses of records or functions can either use fully qualified name or simple name .
pub fn parse_qualified_name(mut cursor: ParseCursor) -> ParseRes<FQIdentifierLexeme> {
    if let Lexeme::Identifier(root_iden) = cursor.take()? {
        //TODO @mark: is this clone needed?
        let mut full_name = root_iden.clone();
        let mut tail_cursor = cursor.fork();
        loop {
            match cursor.take() {
                Ok(Lexeme::Period(separator)) => {
                    let separator_copy = separator.clone();
                    if let Lexeme::Identifier(sub_iden) = cursor.take()? {
                        debug_assert!(sub_iden.is_simple());
                        full_name = full_name.join(&separator_copy, sub_iden);
                        tail_cursor = cursor.fork();
                        continue;
                    }
                }
                Ok(_) | Err(End) => {}
            }
            return Ok((tail_cursor, full_name));
        }
    }
    Err(NoMatch)
}
pub fn parse_qualified_name ( mut cursor : ParseCursor ) -> ParseRes < FQIdentifierLexeme > { if let Lexeme :: Identifier ( root_iden ) = cursor . take ( ) ? { //TODO @mark: is this clone needed? let mut full_name = root_iden . clone ( ) ; let mut tail_cursor = cursor . fork ( ) ; loop { match cursor . take ( ) { Ok ( Lexeme :: Period ( separator ) ) => { let separator_copy = separator . clone ( ) ; if let Lexeme :: Identifier ( sub_iden ) = cursor . take ( ) ? { debug_assert ! ( sub_iden is_simple ( ) ) ; full_name = full_name . join ( & separator_copy , sub_iden ) ; tail_cursor = cursor . fork ( ) ; continue ; } } Ok ( _ ) | Err ( End ) => { } } return Ok ( ( tail_cursor , full_name ) ) ; } } Err ( NoMatch ) }
TODO @mark: tests for FQNs
Parse a qualified name, which is (identifier + period)* + identifier
TODO @mark : tests for FQNs Parse a qualified name which is ( identifier + period ) * + identifier
cursor
ParseCursor