Skip to content

Commit 63857c9

Browse files
committed
Rename LPython to LC
1 parent b344aeb commit 63857c9

File tree

10 files changed

+73
-69
lines changed

10 files changed

+73
-69
lines changed

src/lc/LC.asdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- ASDL's 4 builtin types are:
22
-- identifier, int, string, constant
33

4-
module LPython
4+
module LC
55
{
66
mod = Module(stmt* body, type_ignore* type_ignores)
77
| Interactive(stmt* body)

src/lc/parser/parser.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#include <libasr/utils.h>
1212
#include <lc/parser/parser_exception.h>
1313

14-
namespace LCompilers::LPython {
14+
namespace LCompilers::LC {
1515

16-
Result<LPython::AST::Module_t*> parse(Allocator &al, const std::string &s,
16+
Result<LC::AST::Module_t*> parse(Allocator &al, const std::string &s,
1717
uint32_t prev_loc, diag::Diagnostics &diagnostics)
1818
{
1919
Parser p(al, diagnostics);
@@ -37,7 +37,7 @@ Result<LPython::AST::Module_t*> parse(Allocator &al, const std::string &s,
3737
l.first=p.result[0]->base.loc.first;
3838
l.last=p.result[p.result.size()-1]->base.loc.last;
3939
}
40-
return (LPython::AST::Module_t*)LPython::AST::make_Module_t(al, l,
40+
return (LC::AST::Module_t*)LC::AST::make_Module_t(al, l,
4141
p.result.p, p.result.size(), p.type_ignore.p, p.type_ignore.size());
4242
}
4343

@@ -111,20 +111,20 @@ std::string unique_filename(const std::string &prefix) {
111111
return filename;
112112
}
113113

114-
Result<LPython::AST::ast_t*> parse_python_file(Allocator &al,
114+
Result<LC::AST::ast_t*> parse_python_file(Allocator &al,
115115
const std::string &/*runtime_library_dir*/,
116116
const std::string &infile,
117117
diag::Diagnostics &diagnostics,
118118
uint32_t prev_loc,
119119
[[maybe_unused]] bool new_parser) {
120-
LPython::AST::ast_t* ast;
120+
LC::AST::ast_t* ast;
121121
// We will be using the new parser from now on
122122
new_parser = true;
123123
LCOMPILERS_ASSERT(new_parser)
124124
std::string input = read_file(infile);
125-
Result<LPython::AST::Module_t*> res = parse(al, input, prev_loc, diagnostics);
125+
Result<LC::AST::Module_t*> res = parse(al, input, prev_loc, diagnostics);
126126
if (res.ok) {
127-
ast = (LPython::AST::ast_t*)res.result;
127+
ast = (LC::AST::ast_t*)res.result;
128128
} else {
129129
LCOMPILERS_ASSERT(diagnostics.has_error())
130130
return Error();
@@ -133,4 +133,4 @@ Result<LPython::AST::ast_t*> parse_python_file(Allocator &al,
133133
}
134134

135135

136-
} // namespace LCompilers::LPython
136+
} // namespace LCompilers::LC

src/lc/parser/parser.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <libasr/diagnostics.h>
66
#include <lc/parser/tokenizer.h>
77

8-
namespace LCompilers::LPython {
8+
namespace LCompilers::LC {
99

1010
class Parser
1111
{
@@ -16,8 +16,8 @@ class Parser
1616
diag::Diagnostics &diag;
1717
Allocator &m_a;
1818
Tokenizer m_tokenizer;
19-
Vec<LPython::AST::stmt_t*> result;
20-
Vec<LPython::AST::type_ignore_t*> type_ignore;
19+
Vec<LC::AST::stmt_t*> result;
20+
Vec<LC::AST::type_ignore_t*> type_ignore;
2121

2222
Parser(Allocator &al, diag::Diagnostics &diagnostics)
2323
: diag{diagnostics}, m_a{al} {
@@ -31,16 +31,16 @@ class Parser
3131

3232

3333
// Parses Python code to AST
34-
Result<LPython::AST::Module_t*> parse(Allocator &al,
34+
Result<LC::AST::Module_t*> parse(Allocator &al,
3535
const std::string &s, uint32_t prev_loc,
3636
diag::Diagnostics &diagnostics);
3737

38-
Result<LPython::AST::ast_t*> parse_python_file(Allocator &al,
38+
Result<LC::AST::ast_t*> parse_python_file(Allocator &al,
3939
const std::string &runtime_library_dir,
4040
const std::string &infile,
4141
diag::Diagnostics &diagnostics,
4242
uint32_t prev_loc, bool new_parser);
4343

44-
} // namespace LCompilers::LPython
44+
} // namespace LCompilers::LC
4545

4646
#endif

src/lc/parser/parser.yy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%require "3.0"
22
%define api.pure
3-
%define api.value.type {LCompilers::LPython::YYSTYPE}
4-
%param {LCompilers::LPython::Parser &p}
3+
%define api.value.type {LCompilers::LC::YYSTYPE}
4+
%param {LCompilers::LC::Parser &p}
55
%locations
66
%expect 0 // shift/reduce conflicts
77

@@ -31,13 +31,13 @@
3131
#include <lc/parser/tokenizer.h>
3232
#include <lc/parser/semantics.h>
3333

34-
int yylex(LCompilers::LPython::YYSTYPE *yylval, YYLTYPE *yyloc,
35-
LCompilers::LPython::Parser &p)
34+
int yylex(LCompilers::LC::YYSTYPE *yylval, YYLTYPE *yyloc,
35+
LCompilers::LC::Parser &p)
3636
{
3737
return p.m_tokenizer.lex(p.m_a, *yylval, *yyloc, p.diag);
3838
} // ylex
3939

40-
void yyerror(YYLTYPE *yyloc, LCompilers::LPython::Parser &p, const std::string &msg)
40+
void yyerror(YYLTYPE *yyloc, LCompilers::LC::Parser &p, const std::string &msg)
4141
{
4242
p.handle_yyerror(*yyloc, msg);
4343
}

src/lc/parser/parser_exception.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <libasr/exception.h>
55
#include <libasr/diagnostics.h>
66

7-
namespace LCompilers::LPython {
7+
namespace LCompilers::LC {
88

99
namespace parser_local {
1010

src/lc/parser/parser_stype.h

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
#include <libasr/containers.h>
88
#include <libasr/bigint.h>
99

10-
namespace LCompilers::LPython {
10+
namespace LCompilers::LC {
1111

1212
struct Key_Val {
13-
LPython::AST::expr_t* key;
14-
LPython::AST::expr_t* value;
13+
LC::AST::expr_t* key;
14+
LC::AST::expr_t* value;
1515
};
1616

1717
struct Args {
18-
LPython::AST::arguments_t arguments;
18+
LC::AST::arguments_t arguments;
1919
};
2020

2121
struct Arg {
2222
bool default_value;
23-
LPython::AST::arg_t _arg;
24-
LPython::AST::expr_t *defaults;
23+
LC::AST::arg_t _arg;
24+
LC::AST::expr_t *defaults;
2525
};
2626

2727
struct Var_Kw {
@@ -43,30 +43,30 @@ struct Fn_Arg {
4343
};
4444

4545
struct Kw_or_Star_Arg {
46-
LPython::AST::expr_t *star_arg;
47-
LPython::AST::keyword_t *kw_arg;
46+
LC::AST::expr_t *star_arg;
47+
LC::AST::keyword_t *kw_arg;
4848
};
4949

5050
struct Call_Arg {
51-
Vec<LPython::AST::expr_t*> expr;
52-
Vec<LPython::AST::keyword_t> kw;
51+
Vec<LC::AST::expr_t*> expr;
52+
Vec<LC::AST::keyword_t> kw;
5353
};
5454

5555
struct Key_Val_Pattern {
56-
LPython::AST::expr_t* key;
57-
LPython::AST::pattern_t* val;
56+
LC::AST::expr_t* key;
57+
LC::AST::pattern_t* val;
5858
};
5959

6060
union YYSTYPE {
6161
int64_t n;
6262
double f;
6363
Str string;
6464

65-
LPython::AST::ast_t* ast;
66-
Vec<LPython::AST::ast_t*> vec_ast;
65+
LC::AST::ast_t* ast;
66+
Vec<LC::AST::ast_t*> vec_ast;
6767

68-
LPython::AST::alias_t* alias;
69-
Vec<LPython::AST::alias_t> vec_alias;
68+
LC::AST::alias_t* alias;
69+
Vec<LC::AST::alias_t> vec_alias;
7070

7171
Arg *arg;
7272
Vec<Arg*> vec_arg;
@@ -81,27 +81,27 @@ union YYSTYPE {
8181
Key_Val *key_val;
8282
Vec<Key_Val*> vec_key_val;
8383

84-
LPython::AST::withitem_t* withitem;
85-
Vec<LPython::AST::withitem_t> vec_withitem;
84+
LC::AST::withitem_t* withitem;
85+
Vec<LC::AST::withitem_t> vec_withitem;
8686

87-
LPython::AST::keyword_t* keyword;
88-
Vec<LPython::AST::keyword_t> vec_keyword;
87+
LC::AST::keyword_t* keyword;
88+
Vec<LC::AST::keyword_t> vec_keyword;
8989

9090
Kw_or_Star_Arg* kw_or_star;
9191
Vec<Kw_or_Star_Arg> vec_kw_or_star;
9292

9393
Call_Arg *call_arg;
9494

95-
LPython::AST::comprehension_t* comp;
96-
Vec<LPython::AST::comprehension_t> vec_comp;
95+
LC::AST::comprehension_t* comp;
96+
Vec<LC::AST::comprehension_t> vec_comp;
9797

98-
LPython::AST::operatorType operator_type;
98+
LC::AST::operatorType operator_type;
9999

100-
LPython::AST::match_case_t* match_case;
101-
Vec<LPython::AST::match_case_t> vec_match_case;
100+
LC::AST::match_case_t* match_case;
101+
Vec<LC::AST::match_case_t> vec_match_case;
102102

103-
LPython::AST::pattern_t* pattern;
104-
Vec<LPython::AST::pattern_t*> vec_pattern;
103+
LC::AST::pattern_t* pattern;
104+
Vec<LC::AST::pattern_t*> vec_pattern;
105105

106106
Key_Val_Pattern *kw_val_pattern;
107107
Vec<Key_Val_Pattern> vec_kw_val_pattern;
@@ -114,13 +114,13 @@ static_assert(std::is_trivial<YYSTYPE>::value);
114114
// would reduce performance.
115115
// A temporary fix for PowerPC 32-bit, where the following assert fails with (16 == 12).
116116
#ifndef __ppc__
117-
static_assert(sizeof(YYSTYPE) == sizeof(Vec<LPython::AST::ast_t*>));
117+
static_assert(sizeof(YYSTYPE) == sizeof(Vec<LC::AST::ast_t*>));
118118
#endif
119119

120120
static_assert(std::is_standard_layout<Location>::value);
121121
static_assert(std::is_trivial<Location>::value);
122122

123-
} // namespace LCompilers::LPython
123+
} // namespace LCompilers::LC
124124

125125

126126
typedef struct LCompilers::Location YYLTYPE;

src/lc/parser/semantics.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
parser cpp file, nowhere else.
88
99
Note that this is part of constructing the AST from the source code, not the
10-
LPython semantic phase (AST -> ASR).
10+
LC semantic phase (AST -> ASR).
1111
*/
1212

1313
#include <cstring>
@@ -17,19 +17,19 @@
1717
#include <lc/parser/parser_exception.h>
1818

1919
// This is only used in parser.tab.cc, nowhere else, so we simply include
20-
// everything from LCompilers::LPython::AST to save typing:
21-
using namespace LCompilers::LPython::AST;
20+
// everything from LCompilers::LC::AST to save typing:
21+
using namespace LCompilers::LC::AST;
2222
using LCompilers::Location;
2323
using LCompilers::Vec;
24-
using LCompilers::LPython::Key_Val;
25-
using LCompilers::LPython::Args;
26-
using LCompilers::LPython::Arg;
27-
using LCompilers::LPython::Fn_Arg;
28-
using LCompilers::LPython::Args_;
29-
using LCompilers::LPython::Var_Kw;
30-
using LCompilers::LPython::Kw_or_Star_Arg;
31-
using LCompilers::LPython::Call_Arg;
32-
using LCompilers::LPython::Key_Val_Pattern;
24+
using LCompilers::LC::Key_Val;
25+
using LCompilers::LC::Args;
26+
using LCompilers::LC::Arg;
27+
using LCompilers::LC::Fn_Arg;
28+
using LCompilers::LC::Args_;
29+
using LCompilers::LC::Var_Kw;
30+
using LCompilers::LC::Kw_or_Star_Arg;
31+
using LCompilers::LC::Call_Arg;
32+
using LCompilers::LC::Key_Val_Pattern;
3333

3434
static inline char* name2char(const ast_t *n) {
3535
return down_cast2<Name_t>(n)->m_id;
@@ -246,7 +246,7 @@ int dot_count = 0;
246246
#define TERNARY(test, body, orelse, l) make_IfExp_t(p.m_a, l, \
247247
EXPR(test), EXPR(body), EXPR(orelse))
248248

249-
static inline char *extract_type_comment(LCompilers::LPython::Parser &p,
249+
static inline char *extract_type_comment(LCompilers::LC::Parser &p,
250250
Location &loc, LCompilers::Str &s) {
251251
std::string str = s.str();
252252

@@ -534,7 +534,7 @@ static inline Args *FUNC_ARGS_01(Allocator &al, Location &l, Fn_Arg *parameters)
534534
#define ARGS_04(arg, ann, defaults, l) FUNC_ARG(p.m_a, l, \
535535
name2char((ast_t *)arg), EXPR(ann), EXPR(defaults))
536536

537-
static inline void ADD_TYPE_COMMENT_(LCompilers::LPython::Parser &p, Location l,
537+
static inline void ADD_TYPE_COMMENT_(LCompilers::LC::Parser &p, Location l,
538538
Vec<Arg*> &x, LCompilers::Str &type_comment) {
539539
x[x.size() - 1]->_arg.m_type_comment = extract_type_comment(p, l, type_comment);
540540
}
@@ -771,7 +771,7 @@ static inline ast_t* concat_string(Allocator &al, Location &l,
771771
str1 = str1 + str;
772772
tmp = make_ConstantBytes_t(al, l, LCompilers::s2c(al, str1), nullptr);
773773
} else {
774-
throw LCompilers::LPython::parser_local::ParserError(
774+
throw LCompilers::LC::parser_local::ParserError(
775775
"The byte and non-byte literals can not be combined", l);
776776
}
777777
} else {

src/lc/parser/tokenizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#define MAX_PAREN_LEVEL 200
99

10-
namespace LCompilers::LPython {
10+
namespace LCompilers::LC {
1111

1212
class Tokenizer
1313
{
@@ -92,6 +92,6 @@ Result<std::vector<int>> tokens(Allocator &al, const std::string &input,
9292
std::string pickle_token(int token, const YYSTYPE &yystype);
9393

9494

95-
} // namespace LCompilers::LPython
95+
} // namespace LCompilers::LC
9696

9797
#endif // LPYTHON_SRC_PARSER_TOKENIZER_H

src/lc/parser/tokenizer.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <lc/parser/parser.tab.hh>
66
#include <libasr/bigint.h>
77

8-
namespace LCompilers::LPython {
8+
namespace LCompilers::LC {
99

1010
template<int base>
1111
bool adddgt(uint64_t &u, uint64_t d)
@@ -836,4 +836,4 @@ std::string pickle_token(int token, const YYSTYPE &yystype)
836836
}
837837

838838

839-
} // namespace LCompilers::LPython
839+
} // namespace LCompilers::LC

src/libasr/asdl_cpp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,6 +2749,10 @@ def main(argv):
27492749
elif subs["MOD"] == "AST":
27502750
subs["MOD"] = "LFortran::AST"
27512751
subs["lcompiler"] = "lfortran"
2752+
elif subs["MOD"] == "LC":
2753+
subs["MOD"] = "LC::AST"
2754+
subs["mod"] = "ast"
2755+
subs["lcompiler"] = "lpython"
27522756
else:
27532757
subs["lcompiler"] = "lfortran"
27542758
is_asr = (mod.name.upper() == "ASR")

0 commit comments

Comments
 (0)