Skip to content

Commit

Permalink
Updates symbol table. Not complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-6 committed Apr 6, 2024
1 parent 5048475 commit 5ebb6f4
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
1 change: 1 addition & 0 deletions compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ add_subdirectory(pair)
add_subdirectory(linked_list)
add_subdirectory(dyn_array)
add_subdirectory(hash_table)
add_subdirectory(symbol_table)

add_library(AqCompiler STATIC ${SOURCES})

Expand Down
17 changes: 15 additions & 2 deletions compiler/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ class Compiler {
/// ensuring they adhere to the prescribed syntactic organization.
class Parser;

/// \class SymbolTable
/// \brief The `SymbolTable` class maintains a collection of symbols
/// (variables, functions, and other objects) and their associated scopes.
/// \details - **Input**: The symbol table accepts a sequence of tokens,
/// typically generated by a `Lexer` instance, representing the analyzed
/// source code.
/// - **Syntax Analysis**: It applies context-free grammar rules defined for
/// the target programming language to validate the token sequence's
/// structural correctness. This involves recognizing higher-level language
/// constructs (such as expressions, statements, blocks, and declarations),
/// ensuring they adhere to the prescribed syntactic organization.
class SymbolTable;

/// \class Pair
/// \brief The `Pair` template class encapsulates two heterogeneous objects,
/// `T1` and `T2`, into a single entity. It serves as a convenient way to
Expand Down Expand Up @@ -94,8 +107,8 @@ class Compiler {
/// average complexity for most operations, making `HashTable` particularly
/// suitable for large datasets where fast access is crucial.
/// - **Operations**:
/// - **Insertion**: New key-value pairs can be inserted into the table using
/// appropriate member functions.
/// - **Insertion**: New key-value pairs can be inserted into the table
/// using appropriate member functions.
/// - **Retrieval**: Given a key, users can efficiently retrieve the
/// corresponding value.
/// - **Deletion**: Individual entries or entire ranges of entries can be
Expand Down
13 changes: 13 additions & 0 deletions compiler/symbol_table/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 AQ authors, All Rights Reserved.
# This program is licensed under the AQ License. You can find the AQ license in
# the root directory.

cmake_minimum_required(VERSION 3.10)

include_directories(${PROJECT_SOURCE_DIR})

set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/symbol_table.cc)

add_library(AqCompilerSymbolTable STATIC ${SOURCES})

target_link_libraries(AqCompilerSymbolTable PRIVATE AqDebugger)
11 changes: 11 additions & 0 deletions compiler/symbol_table/symbol_table.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2024 AQ authors, All Rights Reserved.
// This program is licensed under the AQ License. You can find the AQ license in
// the root directory.

#include "compiler/symbol_table/symbol_table.h"

#include "debugger/debugger.h"

namespace Aq {

} // namespace Aq
17 changes: 17 additions & 0 deletions compiler/symbol_table/symbol_table.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2024 AQ authors, All Rights Reserved.
// This program is licensed under the AQ License. You can find the AQ license in
// the root directory.

#ifndef AQ_COMPILER_SYMBOL_TABLE_SYMBOL_TABLE_H_
#define AQ_COMPILER_SYMBOL_TABLE_SYMBOL_TABLE_H_

#include <cstddef>

#include "compiler/compiler.h"
#include "debugger/debugger.h"

namespace Aq {
class Compiler::SymbolTable {};
} // namespace Aq

#endif

0 comments on commit 5ebb6f4

Please sign in to comment.