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
2
votes
3 answers

Where does a mutable object argument of a function lives? Is there a symbol table? (Python tutorial 4.7.1)

Going through the python tutorial, in section 4.7.1, a mutable default argument is stored somewhere but I can't seem to find it using dir(), globals(), locals() or f.__dict__. I'm referring to this code: def f(a, L=[]): L.append(a) return…
2
votes
2 answers

Symbol table and semantic analysis for compiler

I'm working on building a compiler (without using any tools -like lex or bison) for a C like language (a simpler one) and have gotten past the lexer and parser. I am not sure the way I am doing the parser is correct or not. Because, so far to do the…
2
votes
1 answer

Why gcc -Og doesn't generate source code-line mapping?

I've got a simple .c file: $ cat a.c int i=0; int j; static int l=4; void k(){} void main(){ k(); } I tried to compile it with "-Og" to enable debug information. GCC man says -Og Optimize debugging experience. -Og enables optimizations…
Troskyvs
  • 7,537
  • 7
  • 47
  • 115
2
votes
1 answer

C++ error: expected primary-expression before 'int'

I am trying to create a symbol table based on input from a file. As of now, I have the code to read the file line-by-line, separate the tokens, and print out the token and its type. Now, I have to find a way to store these values (token and type)…
Chelly S
  • 107
  • 4
  • 13
2
votes
1 answer

Taking unknown variable values into account at compile-time when creating a symbol table in Java

I am creating a compiler for my own programming language for creating bots in Minecraft as the semester project at my university. So far I have successfully created a parser with ANTLR, created my own Abstract Syntax Tree structure and used ANTLR…
2
votes
1 answer

Listing local variables with `nm` command

I am trying to extract information from object file with nm command for some kind of static code analysis in which I have to count numbers of declared variables and functions in a C code. I have went through the documentation of GNU Binutils. I…
taufique
  • 2,701
  • 1
  • 26
  • 40
2
votes
1 answer

Wrong output for C program using symbol tables

I have this code at the moment and am getting an output that I just cant understand. This is my symTable module, which has all the functions needed to manipulate a symbol table. #include #include #include #include…
2
votes
1 answer

How to strip single name from object file on OS X

I am following some Linux instructions on OS X and am stuck on one line: strip -N main my_file.o The OS X version of strip doesn't have an -N option and I've read through the man page twice but am just not sure how to do this. So how do I strip a…
Lye Fish
  • 2,538
  • 15
  • 25
2
votes
1 answer

JavaCC Interpreter (AST to Symbol Table)

I'm getting quite confused about how I can create an javacc interpreter, particularly how to build a symbol table from an AST tree generated previously. Something like this, from this AST: > Program > Id > Id > Id > VarDecl > Type > Id > …
2
votes
0 answers

Interprocedural Data Flow analysis and symbol tables

I have an inter-procedural control flow graph and I want to perform data flow analysis on it. I am using Hashtable for global (level=0), file (level=1) and method (level=2) levels etc. and I push them on the stack starting with level 0. It works…
Junaid
  • 1,668
  • 7
  • 30
  • 51
2
votes
1 answer

Protection against accidental object incompatibility?

TL;DR Protection against binary incompatibility resulting from compiler argument typos in shared, possibly templated headers' preprocessor directives, which control conditional compilation, in different compilation units? Ex. g++ ...…
lampnyx
  • 71
  • 1
  • 5
2
votes
2 answers

Explain this witchcraft!!! (in Perl, with Moose and namespace::autoclean)

So these days I'm working with a project that uses Perl and Moose. I understand Moose is built on MOP. I'm not too familiar with MOP, and I've encountered something I don't understand, and I could use a theoretical explanation. Here is the module…
user240438
2
votes
0 answers

Using Stacks for Symbol Tables or not

I'm working on creating a compiler and have come across some text that suggests two different ways of implementing symbol tables. With one, there is a symbol table for each level of nesting which is stored on a stack. With the second option there…
davelupt
  • 1,845
  • 4
  • 21
  • 32
2
votes
2 answers

How compiler handle default value in Symbol Table

Some programming language allow parameters have default value in function call or attributes in struct has default. Like python or javascript, when we omit some parameters in function call, the default value will be replaced in the function (same as…
1
vote
1 answer

RuntimeError (symbol table overflow (symbol _one_time_conditions.))

My web app now crash that by this error: RuntimeError (symbol table overflow (symbol _one_time_conditions...)): app/controllers/application_controller.rb:3 The error will appear after about 1 day from start, and resume normal after restart the…
Dabidi
  • 397
  • 5
  • 14