Questions tagged [symbol-table]

A `symbol table` is a data structure that maps each identifier in a program's source code to information relating to its declaration or appearance in the source.

A symbol table is used by a language translator (compiler, interpreter...) for associating each identifier in a program's source code with information relating to its declaration or appearance in the source (type, scope level, sometimes location...).

A common implementation technique is to use a hash table implementation. A compiler may use one large symbol table for all symbols or use separated, hierarchical symbol tables for different scopes.

202 questions
1
vote
0 answers

Symbol table entry when using auto return type deduction with templates in C++

Does anyone know the reason why the output of nm -C on an executable that contained a templated function defined with auto return type deduction has the word auto in the symbol table? Why does it need to know the return type was deduced? I had…
TCD
  • 151
  • 1
  • 7
1
vote
1 answer

Why Add Only Present-Symbols to A Shadowing-List?

I wonder if there's another way to resolve a conflict between the symbol and an external symbol from a package I want to use. For example: In CL-USER, I use two packages A and B. Both export the symbol cat, that's to say, there is a conflict…
shynur
  • 334
  • 10
1
vote
1 answer

What is the purpose of placing a HashSet inside of a HashMap?

For example: private HashMap variableName; I understand that HashMap implements Map and doesn't allow duplicate keys and HashSet implements Set and doesn't allow for duplicate values, but what is the purpose of placing a HashSet…
lobjob
  • 13
  • 3
1
vote
1 answer

Undefined reference to symbol in hand-written ELF file

I have hand-written an ELF32 object file that I would like to link via. gcc but I get an undefined reference when I try to use my function/label. I have it defined in a test C file as extern yet this does not change anything. This object file…
agregate
  • 163
  • 6
1
vote
1 answer

How to avoid ambiguity within symbol table lookups?

I have a rather rudimentary symbol table to map a identifier to a symbol, storing VariableSymbols, MethodSymbols, BuiltInTypeSymbols etc. This has worked fine for my simple interpreter. However now I want to implement more advanced symbol types such…
Tom
  • 1,235
  • 9
  • 22
1
vote
1 answer

Why don't we write assemblers and linkers that can handle C++ identifiers?

My understanding of why we use name mangling is that assemblers and linkers can only handle C identifiers. "int foo::bar::baz(const MoreSpam&)" can't be used as a label by any existing assemblers, and existing linkers won't recognize it…
Dante Falzone
  • 111
  • 1
  • 3
  • 16
1
vote
1 answer

Symbol tables and type checking

I have two orthogonal questions related to symbol tables: Should I build the symbol table and perform type checking as I parse the code? Parsing first and then traversing the AST to build the symbol table looks cleaner to me. However, I like the…
Touloudou
  • 2,079
  • 1
  • 17
  • 28
1
vote
1 answer

Symbol Table scope in compilers for object oriented languages

I'm building up a Symbol Table for a compiler of a subset of C++. My question here is how to deal with the scope in objects. I mean, in a normal language such as Pascal we should create a Symbol Table for every scope. But with C++ should I consider…
FranTastic
  • 61
  • 6
1
vote
1 answer

The values for which of the attributes of a token are filled in a symbol table by the lexical analyser

As a token may have different attributes e.g name,type,size etc.I am confused about which of these are filled in by lexical- analyser and which are filled by other phases of compiler.As different compilers may behave differently we may take gcc c…
1
vote
2 answers

How to print symbol's table, symbol name

I want to print symbol's name in symbol table. i'm mapping the the elf to the virtual memory (using mmap), I successfully an accessed to the symbol table, but when trying to print symbol names it fails (an odd string is show, comparing it to the…
Liavba
  • 75
  • 9
1
vote
0 answers

Can "nm" determine whether the undefined symbol is a function or a variable?

Is it possible to distinguish whether a symbol reported by nm is a function symbol or a variable symbol? For example, if nm reports that there is an undefined symbol U the_undefined_symbol How can I know whether the_undefined_symbol is an undefined…
Alexey
  • 710
  • 3
  • 7
  • 19
1
vote
0 answers

What are the symbol table and AST needed for during code compilation?

What are the symbol table and AST needed for during code compilation? I'm trying to a get a basic high level understanding of the code compilation process. I understand the basic steps to be: Lexical analysis Syntax analysis Semantic analysis Code…
1
vote
1 answer

Function to find the second largest key in a symbol table

so im writing a function that will find the second largest key in an un-ordered symbol table using a linked list implementation, the code I have so far isnt working right and was wondering if someone had any tips thanks! public Key secondLargestKey…
Sam M
  • 13
  • 4
1
vote
0 answers

Generating symbol table using Antlr4

I am learning how to generate a symbol table using Antlr4. I came across this example (and the only one so far) but it gives compilation errors for the files generated by Antlr4. (commands: antlr4 Simple.g4 and javac Simple*.java) -bash-4.1$…
Nht_e0
  • 140
  • 4
  • 15
1
vote
0 answers

Creating an AST and manage, at the same time, a symbol Table using Haskell's Happy parsers

I am creating a simple imperative language from scratch, I already have a working syntactic tree, without much complication, it just uses the bottom-up style of parsing to create it using a simple tree data structure. The idea now is to implement a…