#pragma once

#include "Scanner.hh"
#include "Token.hh"

class Parser
{
public:
  explicit Parser (Scanner scanner);

  void
  parse ();

private:
  // Save the current token, and replace it with the next one.
  // If there's an error, throw a ScanError.
  // Return the saved token. 
  Token
  advance ();

  // Check if current token matches `expected`, and advance if so.
  // Otherwise, throw a ParseError. 
  Token
  match (TokenType expected);

  // Check if the current token matches `type`.
  bool
  check (TokenType type) const;

  void
  parseProgram ();

  void
  parseDecl ();

  void
  parseTypeSpec ();

  ...

private:
  Scanner scanner_;
  Token current_;
};
