mirror of
https://github.com/Ed94/gencpp.git
synced 2024-11-10 02:54:53 -08:00
Fixes for serializations found with last commit's test.
Should be fine to move on to next major feature....
This commit is contained in:
parent
34f286d218
commit
00f6c45f15
@ -589,7 +589,7 @@ String AST::to_string()
|
|||||||
|
|
||||||
if ( Name == nullptr)
|
if ( Name == nullptr)
|
||||||
{
|
{
|
||||||
result.append( "struct\n{\n%s\n};", Body->to_string() );
|
result.append_fmt( "struct\n{\n%s\n};", Body->to_string() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,6 +297,7 @@ namespace Parser
|
|||||||
case '#':
|
case '#':
|
||||||
{
|
{
|
||||||
char const* hash = scanner;
|
char const* hash = scanner;
|
||||||
|
Tokens.append( { hash, 1, TokType::Preprocess_Hash, line, column, false } );
|
||||||
|
|
||||||
move_forward();
|
move_forward();
|
||||||
SkipWhitespace();
|
SkipWhitespace();
|
||||||
@ -354,12 +355,13 @@ namespace Parser
|
|||||||
|
|
||||||
if ( current == '\r' )
|
if ( current == '\r' )
|
||||||
{
|
{
|
||||||
move_forward();
|
// move_forward();
|
||||||
|
// token.Length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( current == '\n' )
|
if ( current == '\n' )
|
||||||
{
|
{
|
||||||
move_forward();
|
// move_forward();
|
||||||
// token.Length++;
|
// token.Length++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -483,9 +485,15 @@ namespace Parser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( current == '\r' )
|
||||||
|
{
|
||||||
|
// move_forward();
|
||||||
|
// content.Length++;
|
||||||
|
}
|
||||||
|
|
||||||
if ( current == '\n' )
|
if ( current == '\n' )
|
||||||
{
|
{
|
||||||
move_forward();
|
// move_forward();
|
||||||
// content.Length++;
|
// content.Length++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -826,36 +834,38 @@ namespace Parser
|
|||||||
|
|
||||||
if ( current == '/' )
|
if ( current == '/' )
|
||||||
{
|
{
|
||||||
token.Type = TokType::Comment;
|
token.Type = TokType::Comment_Start;
|
||||||
|
token.Length = 2;
|
||||||
|
Tokens.append( token );
|
||||||
|
|
||||||
move_forward();
|
move_forward();
|
||||||
token.Text = scanner;
|
Token content = { scanner, 1, TokType::Comment, line, column, false };
|
||||||
token.Length = 0;
|
|
||||||
|
|
||||||
while ( left && current != '\n' && current != '\r' )
|
while ( left && current != '\n' && current != '\r' )
|
||||||
{
|
{
|
||||||
move_forward();
|
move_forward();
|
||||||
token.Length++;
|
content.Length++;
|
||||||
}
|
}
|
||||||
|
Tokens.append( content );
|
||||||
|
|
||||||
if ( current == '\r' )
|
if ( current == '\r' )
|
||||||
{
|
{
|
||||||
move_forward();
|
move_forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( current == '\n' )
|
if ( current == '\n' )
|
||||||
{
|
{
|
||||||
move_forward();
|
move_forward();
|
||||||
// token.Length++;
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if ( current == '*' )
|
else if ( current == '*' )
|
||||||
{
|
{
|
||||||
token.Type = TokType::Comment;
|
token.Type = TokType::Comment_Start;
|
||||||
|
token.Length = 2;
|
||||||
|
Tokens.append( token );
|
||||||
|
|
||||||
move_forward();
|
move_forward();
|
||||||
token.Text = scanner;
|
Token content = { scanner, 1, TokType::Comment, line, column, false };
|
||||||
token.Length = 0;
|
|
||||||
|
|
||||||
bool star = current == '*';
|
bool star = current == '*';
|
||||||
bool slash = scanner[1] == '/';
|
bool slash = scanner[1] == '/';
|
||||||
@ -863,14 +873,20 @@ namespace Parser
|
|||||||
while ( left && ! at_end )
|
while ( left && ! at_end )
|
||||||
{
|
{
|
||||||
move_forward();
|
move_forward();
|
||||||
token.Length++;
|
content.Length++;
|
||||||
|
|
||||||
star = current == '*';
|
star = current == '*';
|
||||||
slash = scanner[1] == '/';
|
slash = scanner[1] == '/';
|
||||||
at_end = star && slash;
|
at_end = star && slash;
|
||||||
}
|
}
|
||||||
|
Tokens.append( content );
|
||||||
|
|
||||||
|
Token end = { scanner, 2, TokType::Comment_End, line, column, false };
|
||||||
move_forward();
|
move_forward();
|
||||||
move_forward();
|
move_forward();
|
||||||
|
|
||||||
|
Tokens.append( end );
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto FoundToken;
|
goto FoundToken;
|
||||||
@ -1116,6 +1132,28 @@ internal CodeUsing parse_using ();
|
|||||||
|
|
||||||
constexpr bool inplace_def = true;
|
constexpr bool inplace_def = true;
|
||||||
|
|
||||||
|
internal inline
|
||||||
|
CodeComment parse_comment()
|
||||||
|
{
|
||||||
|
using namespace Parser;
|
||||||
|
push_scope();
|
||||||
|
|
||||||
|
eat( TokType::Comment_Start );
|
||||||
|
|
||||||
|
CodeComment
|
||||||
|
result = (CodeComment) make_code();
|
||||||
|
result->Type = ECode::Comment;
|
||||||
|
result->Content = get_cached_string( currtok );
|
||||||
|
result->Name = result->Content;
|
||||||
|
eat( TokType::Comment );
|
||||||
|
|
||||||
|
if ( check( TokType::Comment_End ) )
|
||||||
|
eat( TokType::Comment_End );
|
||||||
|
|
||||||
|
Context.pop();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
internal inline
|
internal inline
|
||||||
CodeDefine parse_define()
|
CodeDefine parse_define()
|
||||||
{
|
{
|
||||||
@ -2460,6 +2498,9 @@ CodeBody parse_class_struct_body( Parser::TokType which )
|
|||||||
|
|
||||||
Context.Scope->Start = currtok_noskip;
|
Context.Scope->Start = currtok_noskip;
|
||||||
|
|
||||||
|
if ( currtok.Type == TokType::Preprocess_Hash )
|
||||||
|
eat( TokType::Preprocess_Hash );
|
||||||
|
|
||||||
switch ( currtok_noskip.Type )
|
switch ( currtok_noskip.Type )
|
||||||
{
|
{
|
||||||
case TokType::NewLine:
|
case TokType::NewLine:
|
||||||
@ -2467,9 +2508,8 @@ CodeBody parse_class_struct_body( Parser::TokType which )
|
|||||||
eat( TokType::NewLine );
|
eat( TokType::NewLine );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Comment:
|
case TokType::Comment_Start:
|
||||||
member = def_comment( currtok );
|
member = parse_comment();
|
||||||
eat( TokType::Comment );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Access_Public:
|
case TokType::Access_Public:
|
||||||
@ -2819,6 +2859,9 @@ CodeBody parse_global_nspace( CodeT which )
|
|||||||
|
|
||||||
Context.Scope->Start = currtok_noskip;
|
Context.Scope->Start = currtok_noskip;
|
||||||
|
|
||||||
|
if ( currtok.Type == TokType::Preprocess_Hash )
|
||||||
|
eat( TokType::Preprocess_Hash );
|
||||||
|
|
||||||
switch ( currtok_noskip.Type )
|
switch ( currtok_noskip.Type )
|
||||||
{
|
{
|
||||||
case TokType::NewLine:
|
case TokType::NewLine:
|
||||||
@ -2827,9 +2870,8 @@ CodeBody parse_global_nspace( CodeT which )
|
|||||||
eat( TokType::NewLine );
|
eat( TokType::NewLine );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Comment:
|
case TokType::Comment_Start:
|
||||||
member = def_comment( currtok );
|
member = parse_comment();
|
||||||
eat( TokType::Comment );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Class:
|
case TokType::Decl_Class:
|
||||||
@ -3141,6 +3183,9 @@ CodeEnum parse_enum( bool inplace_def )
|
|||||||
|
|
||||||
while ( left && currtok_noskip.Type != TokType::BraceCurly_Close )
|
while ( left && currtok_noskip.Type != TokType::BraceCurly_Close )
|
||||||
{
|
{
|
||||||
|
if ( currtok.Type == TokType::Preprocess_Hash )
|
||||||
|
eat( TokType::Preprocess_Hash );
|
||||||
|
|
||||||
switch ( currtok_noskip.Type )
|
switch ( currtok_noskip.Type )
|
||||||
{
|
{
|
||||||
case TokType::NewLine:
|
case TokType::NewLine:
|
||||||
@ -3148,9 +3193,8 @@ CodeEnum parse_enum( bool inplace_def )
|
|||||||
eat( TokType::NewLine );
|
eat( TokType::NewLine );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Comment:
|
case TokType::Comment_Start:
|
||||||
member = def_comment( currtok );
|
member = parse_comment();
|
||||||
eat( TokType::Comment );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Preprocess_Define:
|
case TokType::Preprocess_Define:
|
||||||
@ -4212,6 +4256,14 @@ CodeUnion parse_union( bool inplace_def )
|
|||||||
|
|
||||||
while ( ! check_noskip( TokType::BraceCurly_Close ) )
|
while ( ! check_noskip( TokType::BraceCurly_Close ) )
|
||||||
{
|
{
|
||||||
|
if ( currtok.Type == TokType::Preprocess_Hash )
|
||||||
|
eat( TokType::Preprocess_Hash );
|
||||||
|
|
||||||
|
if ( currtok.Line >= 3826 )
|
||||||
|
{
|
||||||
|
log_fmt("here");
|
||||||
|
}
|
||||||
|
|
||||||
Code member = { nullptr };
|
Code member = { nullptr };
|
||||||
switch ( currtok_noskip.Type )
|
switch ( currtok_noskip.Type )
|
||||||
{
|
{
|
||||||
@ -4221,9 +4273,8 @@ CodeUnion parse_union( bool inplace_def )
|
|||||||
eat( TokType::NewLine );
|
eat( TokType::NewLine );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Comment:
|
case TokType::Comment_Start:
|
||||||
member = def_comment( currtok );
|
member = parse_comment();
|
||||||
eat( TokType::Comment );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TokType::Decl_Class:
|
case TokType::Decl_Class:
|
||||||
|
@ -34,6 +34,8 @@ namespace Parser
|
|||||||
Entry( Capture_Start, "(" ) \
|
Entry( Capture_Start, "(" ) \
|
||||||
Entry( Capture_End, ")" ) \
|
Entry( Capture_End, ")" ) \
|
||||||
Entry( Comment, "__comment__" ) \
|
Entry( Comment, "__comment__" ) \
|
||||||
|
Entry( Comment_End, "__comment_end__" ) \
|
||||||
|
Entry( Comment_Start, "__comment start__" ) \
|
||||||
Entry( Char, "__character__" ) \
|
Entry( Char, "__character__" ) \
|
||||||
Entry( Comma, "," ) \
|
Entry( Comma, "," ) \
|
||||||
Entry( Decl_Class, "class" ) \
|
Entry( Decl_Class, "class" ) \
|
||||||
@ -56,6 +58,7 @@ namespace Parser
|
|||||||
Entry( NewLine, "__NewLine__" ) \
|
Entry( NewLine, "__NewLine__" ) \
|
||||||
Entry( Number, "__number__" ) \
|
Entry( Number, "__number__" ) \
|
||||||
Entry( Operator, "__operator__" ) \
|
Entry( Operator, "__operator__" ) \
|
||||||
|
Entry( Preprocess_Hash, "#" ) \
|
||||||
Entry( Preprocess_Define, "define") \
|
Entry( Preprocess_Define, "define") \
|
||||||
Entry( Preprocess_If, "if") \
|
Entry( Preprocess_If, "if") \
|
||||||
Entry( Preprocess_IfDef, "ifdef") \
|
Entry( Preprocess_IfDef, "ifdef") \
|
||||||
|
@ -16,6 +16,8 @@ BraceSquare_Close, "]"
|
|||||||
Capture_Start, "("
|
Capture_Start, "("
|
||||||
Capture_End, ")"
|
Capture_End, ")"
|
||||||
Comment, "__comemnt__"
|
Comment, "__comemnt__"
|
||||||
|
Comment_End, "__comment_end__"
|
||||||
|
Comment_Start, "__comment_start__"
|
||||||
Char, "__character__"
|
Char, "__character__"
|
||||||
Comma, ","
|
Comma, ","
|
||||||
Decl_Class, "class"
|
Decl_Class, "class"
|
||||||
@ -38,6 +40,7 @@ Module_Export, "export"
|
|||||||
NewLine, "__new_line__"
|
NewLine, "__new_line__"
|
||||||
Number, "__number__"
|
Number, "__number__"
|
||||||
Operator, "__operator__"
|
Operator, "__operator__"
|
||||||
|
Preprocess_Hash, "#"
|
||||||
Preprocess_Define, "define"
|
Preprocess_Define, "define"
|
||||||
Preprocess_If, "if"
|
Preprocess_If, "if"
|
||||||
Preprocess_IfDef, "ifdef"
|
Preprocess_IfDef, "ifdef"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user