CBMC
jsil_language.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Jsil Language
4 
5 Author: Michael Tautschnig, tautschn@amazon.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_JSIL_JSIL_LANGUAGE_H
13 #define CPROVER_JSIL_JSIL_LANGUAGE_H
14 
15 #include <memory>
16 
17 #include <util/make_unique.h>
18 
19 #include <langapi/language.h>
20 
21 #include "jsil_parse_tree.h"
22 
24 {
25 public:
26  virtual bool preprocess(
27  std::istream &instream,
28  const std::string &path,
29  std::ostream &outstream) override;
30 
31  virtual bool parse(
32  std::istream &instream,
33  const std::string &path) override;
34 
35  virtual bool generate_support_functions(
36  symbol_tablet &symbol_table) override;
37 
38  virtual bool typecheck(
39  symbol_tablet &context,
40  const std::string &module) override;
41 
42  virtual void show_parse(std::ostream &out) override;
43 
44  virtual ~jsil_languaget();
46 
47  virtual bool from_expr(
48  const exprt &expr,
49  std::string &code,
50  const namespacet &ns) override;
51 
52  virtual bool from_type(
53  const typet &type,
54  std::string &code,
55  const namespacet &ns) override;
56 
57  virtual bool to_expr(
58  const std::string &code,
59  const std::string &module,
60  exprt &expr,
61  const namespacet &ns) override;
62 
63  virtual std::unique_ptr<languaget> new_language() override
64  { return util_make_unique<jsil_languaget>(); }
65 
66  virtual std::string id() const override { return "jsil"; }
67  virtual std::string description() const override
68  { return "Javascript Intermediate Language"; }
69  virtual std::set<std::string> extensions() const override;
70 
71  virtual void modules_provided(std::set<std::string> &modules) override;
72  virtual bool interfaces(symbol_tablet &symbol_table) override;
73 
74 protected:
76  std::string parse_path;
77 };
78 
79 std::unique_ptr<languaget> new_jsil_language();
80 
81 #endif // CPROVER_JSIL_JSIL_LANGUAGE_H
jsil_languaget
Definition: jsil_language.h:23
symbol_tablet
The symbol table.
Definition: symbol_table.h:13
jsil_languaget::typecheck
virtual bool typecheck(symbol_tablet &context, const std::string &module) override
Converting from parse tree and type checking.
Definition: jsil_language.cpp:79
typet
The type of an expression, extends irept.
Definition: type.h:28
jsil_languaget::show_parse
virtual void show_parse(std::ostream &out) override
Definition: jsil_language.cpp:97
jsil_languaget::~jsil_languaget
virtual ~jsil_languaget()
Definition: jsil_language.cpp:169
jsil_languaget::interfaces
virtual bool interfaces(symbol_tablet &symbol_table) override
Adding symbols for all procedure declarations.
Definition: jsil_language.cpp:35
exprt
Base class for all expressions.
Definition: expr.h:55
jsil_languaget::modules_provided
virtual void modules_provided(std::set< std::string > &modules) override
Definition: jsil_language.cpp:29
jsil_languaget::parse_tree
jsil_parse_treet parse_tree
Definition: jsil_language.h:75
jsil_languaget::to_expr
virtual bool to_expr(const std::string &code, const std::string &module, exprt &expr, const namespacet &ns) override
Parses the given string into an expression.
Definition: jsil_language.cpp:125
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
jsil_parse_treet
Definition: jsil_parse_tree.h:100
make_unique.h
jsil_languaget::new_language
virtual std::unique_ptr< languaget > new_language() override
Definition: jsil_language.h:63
jsil_languaget::jsil_languaget
jsil_languaget()
Definition: jsil_language.h:45
jsil_languaget::parse_path
std::string parse_path
Definition: jsil_language.h:76
new_jsil_language
std::unique_ptr< languaget > new_jsil_language()
Definition: jsil_language.cpp:102
language.h
jsil_languaget::description
virtual std::string description() const override
Definition: jsil_language.h:67
jsil_languaget::from_type
virtual bool from_type(const typet &type, std::string &code, const namespacet &ns) override
Formats the given type in a language-specific way.
Definition: jsil_language.cpp:116
jsil_languaget::preprocess
virtual bool preprocess(std::istream &instream, const std::string &path, std::ostream &outstream) override
Definition: jsil_language.cpp:44
jsil_languaget::generate_support_functions
virtual bool generate_support_functions(symbol_tablet &symbol_table) override
Create language-specific support functions, such as __CPROVER_start, __CPROVER_initialize and languag...
Definition: jsil_language.cpp:89
jsil_languaget::id
virtual std::string id() const override
Definition: jsil_language.h:66
jsil_parse_tree.h
languaget
Definition: language.h:37
jsil_languaget::extensions
virtual std::set< std::string > extensions() const override
Definition: jsil_language.cpp:24
jsil_languaget::parse
virtual bool parse(std::istream &instream, const std::string &path) override
Definition: jsil_language.cpp:53
jsil_languaget::from_expr
virtual bool from_expr(const exprt &expr, std::string &code, const namespacet &ns) override
Formats the given expression in a language-specific way.
Definition: jsil_language.cpp:107