diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-07-30 17:01:40 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-07-30 17:01:40 +0200 |
| commit | d690d2f5f862af5766e4496f9a92671d490ad806 (patch) | |
| tree | 4a4b45282d900b996f79c5eb0dd712bfec96fec7 /src/StyleReader.cs | |
| parent | be8a4c2923ee9a62646590576cdf2fcdbf0d39a3 (diff) | |
cumulative styling
Diffstat (limited to 'src/StyleReader.cs')
| -rw-r--r-- | src/StyleReader.cs | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/StyleReader.cs b/src/StyleReader.cs index c1cc28bf..5060b3d9 100644 --- a/src/StyleReader.cs +++ b/src/StyleReader.cs @@ -40,6 +40,8 @@ namespace Crow List<string> targetsClasses = new List<string> (); string currentProperty = ""; + int curlyBracketCount = 0; + while (!EndOfStream) { char c = (Char)Read (); @@ -90,25 +92,43 @@ namespace Crow token += c; break; case readerState.expression: - if (c == ';') { - if (!string.IsNullOrEmpty (token)) { - string expression = token.Trim (); + if (curlyBracketCount == 0) { + if (c == '{'){ + if (string.IsNullOrEmpty(token)) + throw new Exception ("Unexpected token '{'"); + curlyBracketCount++; + token = "{"; + }else if (c == '}') + throw new Exception ("Unexpected token '{'"); + else if (c == ';') { + if (!string.IsNullOrEmpty (token)) { + string expression = token.Trim (); - foreach (string tc in targetsClasses) { - if (!iface.Styling.ContainsKey (tc)) - iface.Styling [tc] = new Dictionary<string, string> (); - else if (iface.Styling [tc].ContainsKey (currentProperty)) - continue; - iface.Styling [tc] [currentProperty] = expression; + foreach (string tc in targetsClasses) { + if (!iface.Styling.ContainsKey (tc)) + iface.Styling [tc] = new Dictionary<string, string> (); + else if (iface.Styling [tc].ContainsKey (currentProperty)) + continue; + iface.Styling [tc] [currentProperty] = expression; + } + token = ""; } - token = ""; - } - state = readerState.propertyName; - } else + state = readerState.propertyName; + } else + token += c; + } else { + if (c == '{') + curlyBracketCount++; + else if (c == '}') + curlyBracketCount--; token += c; + } break; } - } + } + + if (curlyBracketCount > 0) + throw new Exception ("Unexpected end of file"); } } } |