Navigation Menu

Skip to content

Commit

Permalink
Parser internal refactor: ParseVarAssignmentNode
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlopez committed Feb 8, 2016
1 parent e40e5d5 commit 1832733
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions LICENSE
@@ -1,5 +1,8 @@

Copyright (C) 2014, Angel J Lopez
http://www.ajlopez.com
http://ajlopez.wordpress.com
http://twitter.com/ajlopez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 11 additions & 8 deletions Src/SharpGo.Core/Compiler/Parser.cs
Expand Up @@ -184,14 +184,7 @@ private IStatementNode ParseSimpleStatementNode(bool canHaveLabel = false)
return this.ParseVarNode();

if (this.TryParseToken(TokenType.Operator, ":="))
{
TypeInfo typeinfo = this.TryParseTypeInfo();

if (typeinfo is ArrayTypeInfo || typeinfo is SliceTypeInfo)
return new VarNode(token.Value, typeinfo, this.ParseBlockExpressionNode());

return new VarNode(token.Value, typeinfo, this.ParseExpressionNode());
}
return this.ParseVarAssignmentNode(token);

if (this.TryParseToken(TokenType.Delimiter, ":"))
return new LabelNode(token.Value, this.ParseSimpleStatementNode());
Expand Down Expand Up @@ -367,6 +360,16 @@ private IStatementNode ParseSimpleStatementNode(bool canHaveLabel = false)
return cmd;
}

private IStatementNode ParseVarAssignmentNode(Token token)
{
TypeInfo typeinfo = this.TryParseTypeInfo();

if (typeinfo is ArrayTypeInfo || typeinfo is SliceTypeInfo)
return new VarNode(token.Value, typeinfo, this.ParseBlockExpressionNode());

return new VarNode(token.Value, typeinfo, this.ParseExpressionNode());
}

private VarNode ParseVarNode()
{
var name = this.ParseName();
Expand Down

0 comments on commit 1832733

Please sign in to comment.