Skip to content

Commit

Permalink
groups
Browse files Browse the repository at this point in the history
  • Loading branch information
czhower committed Aug 27, 2017
1 parent 2d3e96b commit 1cdbcf4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions source/Spruce/Tokens/Token.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using Spruce.Attribs;
Expand Down Expand Up @@ -107,8 +108,26 @@ protected virtual object Parse(string aText, ref int rStart) {

protected void AddEmitter(Action aEmitter, params Type[] aTokenTypes) {
var xToken = this;
foreach (var xType in aTokenTypes) {
xToken = xToken.AddToken(xType);
for (int i = 0; i < aTokenTypes.Length; i++) {
var xType = aTokenTypes[i];
if (xType.IsDefined(typeof(GroupToken), false)) {
// Group token, need to split tree
var xGroupAttrib = xType.GetCustomAttribute<GroupToken>();
// New array with each group token + rest that follow.
// Copy rest but leave first slot open.
var xTokenTypes = new Type[aTokenTypes.Length - i];
for (int j = 1; j < aTokenTypes.Length - i; j++) {
xTokenTypes[j] = aTokenTypes[i + j];
}
foreach (var xGroupType in xGroupAttrib.TokenTypes) {
xTokenTypes[0] = xGroupType;
xToken.AddEmitter(aEmitter, xTokenTypes);
}
break;
} else {
// Single token
xToken = xToken.AddToken(xType);
}
}

if (xToken.mTokens.Count > 0) {
Expand Down
1 change: 1 addition & 0 deletions source/XSharp/ToDo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ groups to add regxx etc
register class from assembler, wtih size etc.. then to string and convert
comparisons as group token
IfPredicate - { and return - goto has value. Can compound front intead wtih compuonds, ie {if, compare, return/goto abc123/{ as sep attribs}
syntax tree dump

Kudzu ----------------------------------------------------
*** PrivateAssets to G3
Expand Down

0 comments on commit 1cdbcf4

Please sign in to comment.