c2c/Parser/Parser.cpp
/// ParseTopLevelDef - Parse one top-level declaration, return whatever the
/// action tells us to.  This returns true if the EOF was encountered.
/*
    Syntax:
        <public> type ..
        <public> func ..
        <public> type_qualifier ..
        identifier += init_value
*/
Parse one top-level declaration, return whatever the
action tells us to.  This returns true if the EOF was encountered.


Parse one top - level declaration return whatever the action tells us to . This returns true if the EOF was encountered .
bool Parser::ParseTopLevel() {
    LOG_FUNC
    if (Tok.getKind() == tok::identifier && NextToken().getKind() == tok::plusequal) {
        ParseArrayEntry();
        return false;
    }
    bool is_public = ParseOptionalAccessSpecifier();
    switch (Tok.getKind()) {
    case tok::eof:
        return true;
    case tok::kw_import:
        Diag(Tok, diag::err_import_after_decls);
        SkipUntil(tok::semi);
        break;
    case tok::kw_type:
        ParseTypeDef(is_public);
        break;
    case tok::kw_func:
        ParseFuncDef(is_public);
        break;
    case tok::kw_static_assert:
        if (is_public) {
        }
        ParseStaticAssert();
        break;
    default:
        ParseVarDef(is_public);
        break;
    }
    return false;
}
bool Parser :: ParseTopLevel ( ) { LOG_FUNC if ( Tok . getKind ( ) == tok :: identifier && NextToken ( ) . getKind ( ) == tok :: plusequal ) { ParseArrayEntry ( ) ; return false ; } bool is_public = ParseOptionalAccessSpecifier ( ) ; switch ( Tok . getKind ( ) ) { case tok :: eof : return true ; case tok :: kw_import : Diag ( Tok , diag :: err_import_after_decls ) ; SkipUntil ( tok :: semi ) ; break ; case tok :: kw_type : ParseTypeDef ( is_public ) ; break ; case tok :: kw_func : ParseFuncDef ( is_public ) ; break ; case tok :: kw_static_assert : if ( is_public ) { } ParseStaticAssert ( ) ; break ; default : ParseVarDef ( is_public ) ; break ; } return false ; }
ParseTopLevelDef - Parse one top-level declaration, return whatever the
action tells us to.
ParseTopLevelDef - Parse one top - level declaration return whatever the action tells us to .
// TODO error