Skip to content
Permalink
Browse files

[triton/ast] renamed ast -> lang in namespace and file structure

  • Loading branch information...
ptillet committed May 28, 2019
1 parent d2a46af commit 383b5b2a2afb11f0100d6fd96031c0817c95d06f
@@ -6,8 +6,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# FLEX/YACC
find_package(BISON)
find_package(FLEX)
BISON_TARGET(Parser ${CMAKE_CURRENT_SOURCE_DIR}/include/triton/ast/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp)
FLEX_TARGET(Lexer ${CMAKE_CURRENT_SOURCE_DIR}/include/triton/ast/scanner.l ${CMAKE_CURRENT_BINARY_DIR}/scanner.cpp)
BISON_TARGET(Parser ${CMAKE_CURRENT_SOURCE_DIR}/include/triton/lang/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp)
FLEX_TARGET(Lexer ${CMAKE_CURRENT_SOURCE_DIR}/include/triton/lang/scanner.l ${CMAKE_CURRENT_BINARY_DIR}/scanner.cpp)
get_filename_component(BISON_Parser_INCLUDE_DIRECTORIES ${BISON_Parser_OUTPUT_HEADER} DIRECTORY)
include_directories(${BISON_Parser_INCLUDE_DIRECTORIES})

This file was deleted.

@@ -10,7 +10,7 @@

namespace triton{

namespace ast{
namespace lang{

class iteration_statement;
class compound_statement;
@@ -43,7 +43,7 @@ class module {
typedef std::map<std::string, global_value*> symbols_map_t;
typedef std::vector<function*> functions_list_t;
struct current_iteration_info_t{
ast::iteration_statement *statement;
lang::iteration_statement *statement;
basic_block *block;
};

@@ -1,12 +1,8 @@
#ifndef TRITON_INCLUDE_AST_DECLARATION_H
#define TRITON_INCLUDE_AST_DECLARATION_H
#ifndef TRITON_INCLUDE_LANG_DECLARATION_H
#define TRITON_INCLUDE_LANG_DECLARATION_H

#include "node.h"
#include "parser.hpp"
#include <cassert>
#include <vector>
#include <string>
#include <iostream>


namespace triton{
@@ -20,7 +16,7 @@ namespace ir{
class module;
}

namespace ast{
namespace lang{

class expression;
class pointer;
@@ -0,0 +1,20 @@
#ifndef TRITON_INCLUDE_LANG_ERROR_H
#define TRITON_INCLUDE_LANG_ERROR_H

#include "parser.hpp"


namespace triton{
namespace lang{


void update_location(const char *t);
void print_error(const char *error);
char return_impl(char t, const char * yytext);
yytokentype return_impl(yytokentype t, const char * yytext);
void return_void(const char * yytext);

}
}

#endif
@@ -1,8 +1,7 @@
#ifndef TDL_INCLUDE_AST_EXPRESSION_H
#define TDL_INCLUDE_AST_EXPRESSION_H
#ifndef TDL_INCLUDE_LANG_EXPRESSION_H
#define TDL_INCLUDE_LANG_EXPRESSION_H

#include "parser.hpp"
#include "ast.h"
#include "lang.h"
#include <cassert>
#include <vector>
#include <string>
@@ -20,7 +19,7 @@ namespace ir{
class module;
}

namespace ast{
namespace lang{


enum slice_enum_t{
@@ -1,12 +1,13 @@
#ifndef TRITON_INCLUDE_AST_AST_H
#define TRITON_INCLUDE_AST_AST_H
#ifndef TRITON_INCLUDE_LANG_LANG_H
#define TRITON_INCLUDE_LANG_LANG_H

#include "ops.h"
#include "parser.hpp"
#include "declaration.h"
#include "error.h"
#include "expression.h"
#include "node.h"
#include "ops.h"
#include "module.h"
#include "statement.h"

#endif
@@ -1,17 +1,10 @@
#ifndef TRITON_INCLUDE_AST_MODULE_H
#define TRITON_INCLUDE_AST_MODULE_H
#ifndef TRITON_INCLUDE_LANG_MODULE_H
#define TRITON_INCLUDE_LANG_MODULE_H

#include "ops.h"
#include "parser.hpp"
#include "node.h"
#include <cassert>
#include <vector>
#include <string>
#include <iostream>


namespace triton{
namespace ast{
namespace lang{

/* Translation Unit */
class translation_unit: public node{
@@ -1,13 +1,8 @@
#ifndef TRITON_INCLUDE_AST_NODE_H
#define TRITON_INCLUDE_AST_NODE_H
#ifndef TRITON_INCLUDE_LANG_NODE_H
#define TRITON_INCLUDE_LANG_NODE_H

#include "ops.h"
#include "parser.hpp"
#include <cassert>
#include <vector>
#include <string>
#include <iostream>

#include "ops.h"

namespace triton{

@@ -20,7 +15,7 @@ namespace ir{
class module;
}

namespace ast{
namespace lang{

class expression;
class pointer;
@@ -1,14 +1,8 @@
#ifndef TRITON_INCLUDE_AST_OPS_H
#define TRITON_INCLUDE_AST_OPS_H

#include "parser.hpp"
#include <cassert>
#include <vector>
#include <string>
#include <iostream>
#ifndef TRITON_INCLUDE_LANG_OPS_H
#define TRITON_INCLUDE_LANG_OPS_H

namespace triton{
namespace ast{
namespace lang{

enum ASSIGN_OP_T{
ASSIGN,
@@ -2,16 +2,13 @@

%{
namespace triton{
namespace ast{
namespace lang{
class node;
}
}
using namespace triton::ast;
using namespace triton::lang;
#define YYSTYPE node*
#include "../include/triton/ast/ast.h"
#include "../include/triton/ast/expression.h"
#include "../include/triton/ast/statement.h"
#include "../include/triton/ast/declaration.h"
#include "../include/triton/lang/lang.h"

extern char* yytext;
void yyerror(const char *s);
@@ -150,8 +147,8 @@ primary_expression_list

/* Postfix */
slice
: ':' { $$ = new slice(triton::ast::ALL); }
| NEWAXIS { $$ = new slice(triton::ast::NEWAXIS); }
: ':' { $$ = new slice(triton::lang::ALL); }
| NEWAXIS { $$ = new slice(triton::lang::NEWAXIS); }

slice_list
: slice { $$ = new list<slice*>((slice*)$1); }
@@ -387,6 +384,15 @@ storage_class_specifier
| CONSTANT_SPACE { $$ = new token(CONSTANT_SPACE_T); }
;

external_declaration
: function_definition { $$ = $1; }
| declaration { $$ = $1; }
;

function_definition
: declaration_specifiers declarator compound_statement { $$ = new function_definition($1, $2, $3); }
;

/* -------------------------- */
/* Translation Unit */
/* -------------------------- */
@@ -395,15 +401,7 @@ translation_unit
: external_declaration { ast_root = new translation_unit($1); $$ = ast_root; }
| translation_unit external_declaration { $$ = ((translation_unit*)($1))->add($2); }
;

external_declaration
: function_definition { $$ = $1; }
| declaration { $$ = $1; }
;

function_definition
: declaration_specifiers declarator compound_statement { $$ = new function_definition($1, $2, $3); }
;


%%
void yyerror (const char *s){
@@ -8,9 +8,9 @@ IS (u|U|l|L)*
%{
#include <stdio.h>
#include "parser.hpp"
#include "../include/triton/ast/ast.h"
using triton::ast::return_impl;
using triton::ast::return_void;
#include "../include/triton/lang/lang.h"
using triton::lang::return_impl;
using triton::lang::return_void;
%}

%%
@@ -1,13 +1,7 @@
#ifndef TRITON_INCLUDE_AST_STATEMENT_H
#define TRITON_INCLUDE_AST_STATEMENT_H

#include "parser.hpp"
#include "triton/ast/ast.h"
#include <cassert>
#include <vector>
#include <string>
#include <iostream>
#ifndef TRITON_INCLUDE_LANG_STATEMENT_H
#define TRITON_INCLUDE_LANG_STATEMENT_H

#include "expression.h"

namespace triton{

@@ -20,7 +14,7 @@ namespace ir{
class module;
}

namespace ast{
namespace lang{

class declaration;

@@ -1,5 +1,5 @@
#include "triton/ast/statement.h"
#include "triton/ast/declaration.h"
#include "triton/lang/statement.h"
#include "triton/lang/declaration.h"
#include "triton/ir/function.h"
#include "triton/ir/module.h"
#include "triton/ir/basic_block.h"
@@ -9,7 +9,7 @@

namespace triton{

namespace ast{
namespace lang{

/* Declaration specifier */
ir::type* typed_declaration_specifier::type(ir::module *mod) const {
@@ -1,9 +1,10 @@
#include "triton/ast/error.h"
#include <iostream>
#include "triton/lang/error.h"


namespace triton{

namespace ast{
namespace lang{

static int current_line = 0;
static int current_column = 0;
@@ -1,5 +1,5 @@
#include "triton/ast/expression.h"
#include "triton/ast/declaration.h"
#include "triton/lang/expression.h"
#include "triton/lang/declaration.h"
#include "triton/ir/constant.h"
#include "triton/ir/module.h"
#include "triton/ir/builder.h"
@@ -8,7 +8,7 @@

namespace triton{

namespace ast{
namespace lang{


/* Binary operator */

0 comments on commit 383b5b2

Please sign in to comment.
You can’t perform that action at this time.