Exemple #1
0
 /// <summary>
 /// Parse node contents add return a fresh node.
 /// </summary>
 /// <param name="prototypes">List containing all node types</param>
 /// <param name="parent">Node that this is a subnode to. Can be null</param>
 /// <param name="line">Line to parse</param>
 /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
 /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
 /// <exception cref="Exceptions.CodeGeneratorException"></exception>
 public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
 {
     offset = line.Data.Length;
     return new DocTypeTag(
         @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">".Replace("\"", "\"\""),
         parent);
 }
Exemple #2
0
        /// <summary>
        /// Parse node contents add return a fresh node.
        /// </summary>
        /// <param name="prototypes">List containing all node types</param>
        /// <param name="parent">Node that this is a subnode to. Can be null</param>
        /// <param name="line">Line to parse</param>
        /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
        /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
        /// <exception cref="Exceptions.CodeGeneratorException"></exception>
        public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
        {
            // text on tag rows are identified by a single space.
            if (parent != null && line.Data[offset] == ' ')
                ++offset;

            TextNode node = new TextNode(parent, line.Data.Substring(offset));
            if (parent == null)
                node.LineInfo = line;
            offset = line.Data.Length;
            return node;
        }
Exemple #3
0
        /// <summary>
        /// Parse node contents add return a fresh node.
        /// </summary>
        /// <param name="prototypes">List containing all node types</param>
        /// <param name="parent">Node that this is a subnode to. Can be null</param>
        /// <param name="line">Line to parse</param>
        /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
        /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
        /// <exception cref="CodeGeneratorException"></exception>
        public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
        {
            if (offset > line.Data.Length)
                throw new CodeGeneratorException(line.LineNumber, line.Data, "Too little data");

            int pos = line.Data.Length;
            ++offset;
            string code = line.Data.Substring(offset, pos - offset);
            offset = pos;

            SilentCodeNode node = (SilentCodeNode)prototypes.CreateNode("-", parent);
            node._code = code;
            if (parent != null)
                node.LineInfo = line;
            return node;
        }
Exemple #4
0
        /// <summary>
        /// Parse node contents add return a fresh node.
        /// </summary>
        /// <param name="prototypes">List containing all node types</param>
        /// <param name="parent">Node that this is a subnode to. Can be null</param>
        /// <param name="line">Line to parse</param>
        /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
        /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
        /// <exception cref="CodeGeneratorException"></exception>
        public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
        {
            if (offset > line.Data.Length - 1)
                throw new CodeGeneratorException(line.LineNumber, line.Data, "Too little data");

            int pos = GetEndPos(offset, line.Data);
            if (pos == -1)
                pos = line.Data.Length;

            ++offset;
            string name = line.Data.Substring(offset, pos - offset);
            offset = pos;

            ClassNode node = (ClassNode)prototypes.CreateNode(".", parent);
            node._name = name;
            return AddMe(prototypes, parent, line, node);
        }
Exemple #5
0
        /// <summary>
        /// Parse node contents add return a fresh node.
        /// </summary>
        /// <param name="prototypes">List containing all node types</param>
        /// <param name="parent">Node that this is a subnode to. Can be null</param>
        /// <param name="line">Line to parse</param>
        /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
        /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
        /// <exception cref="CodeGeneratorException"></exception>
        public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
        {
            if (line.Data[offset] != '#')
                throw new CodeGeneratorException(line.LineNumber, line.Data, "Node is not an id node.");

            int endPos = GetEndPos(offset, line.Data);
            if (endPos == -1)
                endPos = line.Data.Length;

            ++offset;
            string id = line.Data.Substring(offset, endPos - offset);
            offset = endPos;

            IdNode node = (IdNode)prototypes.CreateNode("#", parent);
            node._id = id;
            return AddMe(prototypes, parent, line, node);
        }
Exemple #6
0
        /// <summary>
        /// Parse node contents add return a fresh node.
        /// </summary>
        /// <param name="prototypes">List containing all node types</param>
        /// <param name="parent">Node that this is a subnode to. Can be null</param>
        /// <param name="line">Line to parse</param>
        /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
        /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
        /// <exception cref="CodeGeneratorException"></exception>
        public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
        {
            if (offset >= line.Data.Length)
                throw new CodeGeneratorException(line.LineNumber, line.Data, "Too little data");

            int pos = line.Data.Length;

            ++offset;
            string name = line.Data.Substring(offset, pos - offset);
            offset = pos;

            string trimmedData = line.Data.Trim();
            if (trimmedData.Length > 0 && trimmedData[trimmedData.Length - 1] == ';')
                throw new CodeGeneratorException(line.LineNumber, line.Data, "Displayed code should not end with semicolon.");

            DisplayCodeNode node = (DisplayCodeNode)prototypes.CreateNode("=", parent);
            node._code = name;
            if (parent == null)
                node.LineInfo = line;
            return node;
        }
Exemple #7
0
 /// <summary>
 /// Contains C# code that will be rendered into the view.
 /// </summary>
 /// <param name="parent">Parent node</param>
 public DisplayCodeNode(Node parent)
     : base(parent)
 {
 }
Exemple #8
0
 private bool IsLastNode(Node parent)
 {
     if (parent == null)
         return false;
     if (parent.ModifierCount == 0)
         return false;
     return parent.LastModifier == this;
 }
Exemple #9
0
 /// <summary>
 /// Add a new node
 /// </summary>
 /// <param name="parent">parent node.</param>
 public Node(Node parent)
 {
     _parent = parent;
 }
Exemple #10
0
 /// <summary>
 /// Parse node contents add return a fresh node.
 /// </summary>
 /// <param name="prototypes">List containing all node types</param>
 /// <param name="parent">Node that this is a subnode to. Can be null</param>
 /// <param name="line">Line to parse</param>
 /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
 /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
 /// <exception cref="Exceptions.CodeGeneratorException"></exception>
 public abstract Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset);
Exemple #11
0
 /// <summary>
 /// Modifiers are used to modify the first node on the line.
 /// Typical modifiers are attribute lists, class names and IDs.
 /// </summary>
 /// <param name="node">Modifier node</param>
 public void AddModifier(Node node)
 {
     if (node.IsTextNode)
         _children.AddLast(node);
     else
         _modifiers.AddLast(node);
 }
Exemple #12
0
 /// <summary>
 /// Create a new node
 /// </summary>
 /// <param name="parent">parent node</param>
 /// <param name="col">collection of attributes</param>
 public AttributeNode(Node parent, List<Attribute> col)
     : base(parent)
 {
     _attributes = col;
 }
Exemple #13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="parent">parent node</param>
 /// <param name="text">plain text</param>
 public TextNode(Node parent, string text)
     : base(parent)
 {
     Text = text;
 }
Exemple #14
0
 public SilentCodeNode(Node parent)
     : base(parent)
 {
 }
Exemple #15
0
 public IdNode(Node parent)
     : base(parent)
 {
 }
Exemple #16
0
        /// <summary>
        /// Parse node contents add return a fresh node.
        /// </summary>
        /// <param name="prototypes">List containing all node types</param>
        /// <param name="parent">Node that this is a subnode to. Can be null</param>
        /// <param name="line">Line to parse</param>
        /// <param name="offset">Where to start the parsing. Should be set to where the next node should start parsing.</param>
        /// <returns>A node corresponding to the bla bla; null if parsing failed.</returns>
        /// <exception cref="CodeGeneratorException"></exception>
        public override Node Parse(NodeList prototypes, Node parent, LineInfo line, ref int offset)
        {
            if (line.Data[offset] != '{')
                throw new CodeGeneratorException(line.LineNumber, line.Data, "Attribute cant handle info at char " + offset + 1);

            int endPos = GetEndPos(offset, line.Data, '}');
            if (endPos == -1)
                throw new CodeGeneratorException(line.LineNumber, line.Data, "Failed to find end of attribute list: '" + line.UnparsedData + "'.");

            List<Attribute> col = new List<Attribute>();
            string attributes = line.Data.Substring(offset + 1, endPos - offset - 1);
            ParseAttributes(line, attributes, col);
            offset = endPos + 1;

            AttributeNode node = (AttributeNode)prototypes.CreateNode("{", parent);
            node._attributes = col;
            return AddMe(prototypes, parent, line, node);
        }
Exemple #17
0
 /// <summary>
 /// create an attribute node
 /// </summary>
 /// <param name="parent">parent node</param>
 public AttributeNode(Node parent)
     : base(parent)
 {
     _attributes = new List<Attribute>();
 }
Exemple #18
0
 public ClassNode(Node parent)
     : base(parent)
 {
 }
Exemple #19
0
 public DocTypeTag(string docType, Node parent)
     : base(parent)
 {
     _docType = docType;
 }