Skip to content

Commit a8cdc87

Browse files
authored
Prefix internal lexer and encoding functions and types (#25)
Part of Shopify/team-ruby-dx#1436
1 parent 5ccb540 commit a8cdc87

10 files changed

Lines changed: 465 additions & 465 deletions

File tree

include/rbs/encoding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "rbs_string.h"
55

6-
unsigned int utf8_to_codepoint(const rbs_string_t string);
6+
unsigned int rbs_utf8_to_codepoint(const rbs_string_t string);
77
int utf8_codelen(unsigned int c);
88

99
#endif // RBS_ENCODING_H

include/rbs/lexer.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "rbs_string.h"
55
#include "rbs_encoding.h"
66

7-
enum TokenType {
7+
enum RBSTokenType {
88
NullType, /* (Nothing) */
99
pEOF, /* EOF */
1010
ErrorToken, /* Error */
@@ -111,7 +111,7 @@ typedef struct {
111111
} range;
112112

113113
typedef struct {
114-
enum TokenType type;
114+
enum RBSTokenType type;
115115
range range;
116116
} token;
117117

@@ -140,21 +140,21 @@ extern token NullToken;
140140
extern position NullPosition;
141141
extern range NULL_RANGE;
142142

143-
char *peek_token(lexstate *state, token tok);
144-
int token_chars(token tok);
145-
int token_bytes(token tok);
143+
char *rbs_peek_token(lexstate *state, token tok);
144+
int rbs_token_chars(token tok);
145+
int rbs_token_bytes(token tok);
146146

147-
#define null_position_p(pos) (pos.byte_pos == -1)
148-
#define null_range_p(range) (range.start.byte_pos == -1)
149-
#define nonnull_pos_or(pos1, pos2) (null_position_p(pos1) ? pos2 : pos1)
150-
#define RANGE_BYTES(range) (range.end.byte_pos - range.start.byte_pos)
147+
#define rbs_null_position_p(pos) (pos.byte_pos == -1)
148+
#define rbs_null_range_p(range) (range.start.byte_pos == -1)
149+
#define rbs_nonnull_pos_or(pos1, pos2) (rbs_null_position_p(pos1) ? pos2 : pos1)
150+
#define RBS_RANGE_BYTES(range) (range.end.byte_pos - range.start.byte_pos)
151151

152-
const char *token_type_str(enum TokenType type);
152+
const char *token_type_str(enum RBSTokenType type);
153153

154154
/**
155155
* Read next character.
156156
* */
157-
unsigned int peek(lexstate *state);
157+
unsigned int rbs_peek(lexstate *state);
158158

159159
/**
160160
* Skip one character.
@@ -164,20 +164,20 @@ void rbs_skip(lexstate *state);
164164
/**
165165
* Skip n characters.
166166
* */
167-
void skipn(lexstate *state, size_t size);
167+
void rbs_skipn(lexstate *state, size_t size);
168168

169169
/**
170170
* Return new token with given type.
171171
* */
172-
token next_token(lexstate *state, enum TokenType type);
172+
token rbs_next_token(lexstate *state, enum RBSTokenType type);
173173

174174
/**
175175
* Return new token with EOF type.
176176
* */
177-
token next_eof_token(lexstate *state);
177+
token rbs_next_eof_token(lexstate *state);
178178

179179
token rbsparser_next_token(lexstate *state);
180180

181-
void print_token(token tok);
181+
void rbs_print_token(token tok);
182182

183183
#endif

include/rbs/parserstate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void parser_advance(parserstate *state);
143143
/**
144144
* Advance one token if the next_token is a token of the type.
145145
* */
146-
bool parser_advance_if(parserstate *state, enum TokenType type);
146+
bool parser_advance_if(parserstate *state, enum RBSTokenType type);
147147
void print_parser(parserstate *state);
148148

149149
/**

src/encoding.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "rbs/encoding.h"
22

3-
unsigned int utf8_to_codepoint(const rbs_string_t string) {
3+
unsigned int rbs_utf8_to_codepoint(const rbs_string_t string) {
44
unsigned int codepoint = 0;
55
int remaining_bytes = 0;
66

0 commit comments

Comments
 (0)