summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parse/lex.cpp14
-rw-r--r--src/parse/root.cpp8
2 files changed, 20 insertions, 2 deletions
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp
index 17eb4f30..4237b48f 100644
--- a/src/parse/lex.cpp
+++ b/src/parse/lex.cpp
@@ -240,7 +240,7 @@ Token Lexer::getToken()
ch = this->getc();
if( ch == 'x' ) {
num_mode = HEX;
- while( isxdigit(ch = this->getc()) )
+ while( isxdigit(ch = this->getc_num()) )
{
val *= 16;
if(ch <= '9')
@@ -253,7 +253,16 @@ Token Lexer::getToken()
}
else if( ch == 'b' ) {
num_mode = BIN;
- throw ParseError::Todo("Lex binary numbers");
+ while( isdigit(ch = this->getc_num()) )
+ {
+ val *= 2;
+ if(ch == '0')
+ val += 0;
+ else if( ch == '1' )
+ val += 1;
+ else
+ throw ParseError::Generic("Invalid digit in binary literal");
+ }
}
else if( isdigit(ch) ) {
num_mode = OCT;
@@ -487,6 +496,7 @@ uint32_t Lexer::parseEscape(char enclosing)
char ch = this->getc();
switch(ch)
{
+ case 'x':
case 'u': {
// Unicode (up to six hex digits)
uint32_t val = 0;
diff --git a/src/parse/root.cpp b/src/parse/root.cpp
index 55f6f21c..b67f620c 100644
--- a/src/parse/root.cpp
+++ b/src/parse/root.cpp
@@ -651,6 +651,14 @@ void Parse_Struct(AST::Module& mod, TokenStream& lex, const bool is_public, cons
::std::vector<AST::StructItem> items;
while( GET_TOK(tok, lex) != TOK_BRACE_CLOSE )
{
+ AST::MetaItems item_attrs;
+ while( tok.type() == TOK_ATTR_OPEN )
+ {
+ item_attrs.push_back( Parse_MetaItem(lex) );
+ GET_CHECK_TOK(tok, lex, TOK_SQUARE_CLOSE);
+ GET_TOK(tok, lex);
+ }
+
bool is_pub = false;
if(tok.type() == TOK_RWORD_PUB) {
is_pub = true;