private void ScanPlaceholder(GenContainerFragmentBase parentContainer, ref GenTextBlock textBlock, bool isPrimary) { AddText(parentContainer, ref textBlock, GenDataDef.GetId(Scan.ScanName()), GenDataDef, isPrimary); if (Scan.CheckChar(Scan.Delimiter)) { Scan.SkipChar(); } }
private GenAnnotation ScanAnnotation(int classId, GenContainerFragmentBase parentContainer, bool isPrimary = true) { var frag = new GenAnnotation(new GenFragmentParams(GenDataDef, parentContainer, isPrimary)); if (Scan.CheckChar('-')) { Scan.SkipChar(); } ScanBody(classId, frag.Body, frag, frag.Annotation); return(frag); }
private void ScanBody(int classId, GenSegBody body, GenContainerFragmentBase parentContainer, ContainerFragment containerFragment) { var saveClassId = GenDataDef.CurrentClassId; GenDataDef.CurrentClassId = classId; if (!Scan.Eof) { TokenType t; CompactPrimaryBodyParser.ScanPartialBody(classId, body, parentContainer, containerFragment, out t); if (t == TokenType.Secondary) { Scan.SkipChar(); CompactSecondaryBodyParser.ScanPartialBody(classId, body, parentContainer, containerFragment, out t); } if (t != TokenType.Close) { if (Scan.Eof && classId != 0) { //throw new Exception("<<<<Missing Segment end bracket>>>>"); OutputText(parentContainer, true, "<<<<Missing Segment end bracket>>>>"); } if (!Scan.Eof) { //throw new Exception("<<<<Unknown text in profile>>>>"); OutputText(parentContainer, true, "<<<<Unknown text in profile>>>>"); } } else { if (Scan.CheckChar(']')) { Scan.SkipChar(); } } } else if (classId != 0) { //throw new Exception("<<<<<Missing Segment end bracket>>>>>"); OutputText(parentContainer, true, "<<<<Unknown text in profile>>>>"); } GenDataDef.CurrentClassId = saveClassId; }
private void ScanBlockParams(GenSegBody body, GenContainerFragmentBase parentContainer, Function function, FragmentBody fragmentBody) { Scan.ScanWhile(ScanReader.WhiteSpace); if (Scan.CheckChar(Scan.Delimiter)) { Scan.SkipChar(); } var t = Scan.ScanTokenType(); while (t != TokenType.Close) { string s; if (t != TokenType.Unknown && t != TokenType.Name) { // Parameter starts with a delimiter if (t != TokenType.Close && t != TokenType.Unknown) { // Scan contained block GenTextBlock textBlock = null; var frag = ScanFragment(GenDataDef.CurrentClassId, ref t, out s, parentContainer, fragmentBody, ref textBlock, true); body.Add(frag ?? textBlock); // Skip blank parameter separators s = s.TrimStart(); if (s != "") { body.Add( new GenTextFragment(new GenTextFragmentParams(GenDataDef, parentContainer, s))); } t = Scan.ScanTokenType(); } } else { // Parameter starts without a delimiter var block = new GenBlock(new GenFragmentParams(GenDataDef, parentContainer)); s = Scan.CheckChar('\'') ? Scan.ScanQuotedString() : Scan.ScanUntil(_parameterSeparator); while (Scan.CheckChar(' ')) { Scan.SkipChar(); } // Scan for Text and Placeholders var i = s.IndexOf(Scan.Delimiter); while (i != -1) { var w = s.Substring(0, i - 1); // Text up to first delimiter s = s.Substring(i + 1); // Text after first delimeter if (s != "") { // Some text after the first delimiter i = s.IndexOf(Scan.Delimiter); // Position of next delimiter if (i != -1) { if (w != "") { // Add Text up to first delimiter block.Body.Add( new GenTextFragment(new GenTextFragmentParams(GenDataDef, parentContainer, w))); } w = s.Substring(0, i - 1); // Text between initial two delimiters block.Body.Add( new GenPlaceholderFragment(new GenPlaceholderFragmentParams(GenDataDef, parentContainer, GenDataDef.GetId(w)))); s = s.Substring(i + 1); i = s.IndexOf(Scan.Delimiter); } else { // No matching delimiter: output delimiter with text block.Body.Add( new GenTextFragment(new GenTextFragmentParams(GenDataDef, parentContainer, w + Scan.Delimiter + s))); s = ""; } } else { // No text after initial delimiter: output delimiter with text block.Body.Add( new GenTextFragment(new GenTextFragmentParams(GenDataDef, parentContainer, w + Scan.Delimiter))); i = -1; } } if (s != "" || block.Body.Count == 0) { // Text without placeholders block.Body.Add( new GenTextFragment(new GenTextFragmentParams(GenDataDef, block, s))); } body.Add(block); if (Scan.CheckChar(Scan.Delimiter)) { Scan.SkipChar(); } t = Scan.ScanTokenType(); } } if (t == TokenType.Close) { Scan.SkipChar(); } }