Skip to content

Commit

Permalink
implementing structs
Browse files Browse the repository at this point in the history
  • Loading branch information
M4GNV5 committed Jan 21, 2016
1 parent 908a4d8 commit c061d93
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cparse.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,19 @@ var cparse = (function()
skipBlanks();
if(lookahead("struct"))
{
throw "structs not yet supported";
var stmt = {type: "StructDefinition", member: []};
stmt.name = readIdentifier();
consume("{");

while(definitionIncoming())
{
var def = readDefinition();
stmt.member.push(def);
consume(";");
}

consume("}");
stmts.push(stmt);
}
else if(lookahead("enum"))
{
Expand Down Expand Up @@ -476,7 +488,7 @@ var cparse = (function()
if(postfix[i] != ":")
throw new Error("Error parsing ternary expression");
i++;

ast.right = toTree();
ast.left = toTree();
ast.condition = toTree();
Expand Down

0 comments on commit c061d93

Please sign in to comment.