CBMC
json_symtab_language.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: JSON symbol table language. Accepts a JSON format symbol
4  table that has been produced out-of-process, e.g. by using
5  a compiler's front-end.
6 
7 Author: Chris Smowton, chris.smowton@diffblue.com
8 
9 \*******************************************************************/
10 
11 #include "json_symtab_language.h"
12 #include "json_symbol_table.h"
13 #include <json/json_parser.h>
14 
15 #include <linking/linking.h>
16 
22  std::istream &instream,
23  const std::string &path)
24 {
25  return parse_json(instream, path, get_message_handler(), parsed_json_file);
26 }
27 
33  symbol_tablet &symbol_table,
34  const std::string &module)
35 {
36  (void)module; // unused parameter
37 
38  symbol_tablet new_symbol_table;
39 
40  try
41  {
42  symbol_table_from_json(parsed_json_file, new_symbol_table);
43  return linking(symbol_table, new_symbol_table, get_message_handler());
44  }
45  catch(const std::string &str)
46  {
47  error() << "typecheck: " << str << eom;
48  return true;
49  }
50 }
51 
55 void json_symtab_languaget::show_parse(std::ostream &out)
56 {
58 }
json_symtab_languaget::show_parse
void show_parse(std::ostream &out) override
Output the result of the parsed json file to the output stream passed as a parameter to this function...
Definition: json_symtab_language.cpp:55
symbol_tablet
The symbol table.
Definition: symbol_table.h:13
linking
bool linking(symbol_tablet &dest_symbol_table, const symbol_tablet &new_symbol_table, message_handlert &message_handler)
Merges the symbol table new_symbol_table into dest_symbol_table, renaming symbols from new_symbol_tab...
Definition: linking.cpp:1475
jsont::output
void output(std::ostream &out) const
Definition: json.h:90
messaget::eom
static eomt eom
Definition: message.h:297
json_parser.h
messaget::error
mstreamt & error() const
Definition: message.h:399
json_symtab_languaget::parse
bool parse(std::istream &instream, const std::string &path) override
Parse a goto program in json form.
Definition: json_symtab_language.cpp:21
linking.h
json_symtab_languaget::parsed_json_file
jsont parsed_json_file
Definition: json_symtab_language.h:72
messaget::get_message_handler
message_handlert & get_message_handler()
Definition: message.h:184
json_symtab_languaget::typecheck
bool typecheck(symbol_tablet &symbol_table, const std::string &module) override
Typecheck a goto program in json form.
Definition: json_symtab_language.cpp:32
parse_json
bool parse_json(std::istream &in, const std::string &filename, message_handlert &message_handler, jsont &dest)
Definition: json_parser.cpp:16
json_symtab_language.h
json_symbol_table.h
symbol_table_from_json
void symbol_table_from_json(const jsont &in, symbol_tablet &symbol_table)
Definition: json_symbol_table.cpp:16