#include <stdio.h>
#include <string.h>
#include "helpers.h"
#include "version.h"
#include "scanner.h"

int main(const int argc, const char *agrv[])
{
    if (argc < 2)
    {
        if (strlen(tag_name) > 0)
        {
            printf("\n%s\nTypephp version %s\n\n", logo, tag_name);
        }
        else
        {
            printf("\n%s\nTypephp version %s-%s\n\n", logo, branch_name, commit_hash);
        }
        printf("USAGE:\n    typephp <filepath>\n\n");
        return 0;
    }

    const char *filename = agrv[1];

    printf("Typephp start parse file: %s\n", filename);

    FILE *fp = fopen(filename, "r");

    char ch;
    while (1)
    {
        ch = scan(fp);
        if (ch == '\0')
        {
            printf("EOF");
            break;
        }
        printf("%c", ch);
    }
    fclose(fp);

    return 0;
}
