<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ananth&#039;s very own website &#187; .NET</title>
	<atom:link href="http://ananthonline.net/category/blog/dotnet/feed" rel="self" type="application/rss+xml" />
	<link>http://ananthonline.net</link>
	<description>Nemo vir est qui mundum non reddat meliorem</description>
	<lastBuildDate>Sun, 29 Jan 2012 05:04:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Quenya &#8211; Beyond syntax</title>
		<link>http://ananthonline.net/2011/08/04/quenya-beyond-syntax/</link>
		<comments>http://ananthonline.net/2011/08/04/quenya-beyond-syntax/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 22:02:53 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Quenya]]></category>

		<guid isPermaLink="false">http://ananthonline.net/?p=294</guid>
		<description><![CDATA[ Tweet <p>Edit &#8211; I have been looking at other alternatives to writing my own parser/language, although I did learn a lot when trying to write my own. Nemerle seems like the most likely candidate to me, given how extensible and C#-like it is. Among mainstream languages, I am also beginning to favor F#. Thanks [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2011%2F08%2F04%2Fquenya-beyond-syntax%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2011/08/04/quenya-beyond-syntax/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2011/08/04/quenya-beyond-syntax/"  data-text="Quenya &#8211; Beyond syntax" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2011/08/04/quenya-beyond-syntax/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p><em><strong>Edit</strong> &#8211; I have been looking at other alternatives to writing my own parser/language, although I did learn a lot when trying to write my own. <a title="Nemerle" href="http://nemerle.org/About/" target="_blank">Nemerle</a> seems like the most likely candidate to me, given how extensible and C#-like it is. Among mainstream languages, I am also beginning to favor <a title="F#" href="http://msdn.microsoft.com/en-us/vstudio/hh388569.aspx" target="_blank">F#</a>. Thanks to everyone in the comments section who pointed out various options to me.</em></p>
<p>I guess it&#8217;s finally time to let people know what I&#8217;ve been working on (and thinking about) for the past six months or so.</p>
<p>The driving force behind this new project is my increasing frustration with existing languages. While most of them have been crafted masterfully, there&#8217;s always something in each that isn&#8217;t available and prevents me from writing the most elegant or readable code for that compiler. With C#, my list of gripes is long and would eat up a whole post. Let&#8217;s just say that while I love C#, there are many features I wish it had. And most of the time, it&#8217;s not something that can&#8217;t be added, it&#8217;s just not in the compiler because</p>
<ul>
<li>The feature probably wasn&#8217;t considered or was cut because it wasn&#8217;t an important use-case</li>
<li>The development team couldn&#8217;t add it in due to time constraints (that&#8217;s fair)</li>
<li>Or they believe it&#8217;s not something that the language needs (these are far more frustrating, because you know they&#8217;re never going to be in the language)</li>
</ul>
<p>Again, I state these without mentioning what it is I want, which is indeed the point of this post. <img src='http://ananthonline.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Without further ado, I present a proposed implementation for my (.NET) compiler which I have dubbed <a title="Quenya" href="http://en.wikipedia.org/wiki/Quenya" target="_blank">Quenya</a> for the time-being. I intended this compiler to be syntax agnostic (or at the very least, <em>extremely extensible</em>) and therefore the bulk of the idea revolves around a way for users to re-define source code and for the compiler to be able to parse it.</p>
<p>Before we begin, I would like to point you to <a title="this" href="http://blogs.msdn.com/b/lukeh/archive/2007/08/19/monadic-parser-combinators-using-c-3-0.aspx" target="_blank">this</a> awesome post by Luke Hoban, who is one of my favorite blog authors ever. I have used the source code for his monadic parser to build Quenya&#8217;s parsing logic.</p>
<p>To allow Quenya to parse something, it is not enough to provide it with source code. Quenya needs a grammar/parser (or a reference to one) and the source to parse. The parser is then expected to return a set of known AST nodes when called upon to parse the source code (linked to that grammar/parser). The rest of the compiler phases then proceed as usual and the compiler spits out IL. The figure below shows an overview of the parsing process in Quenya.</p>
<div id="attachment_295" class="wp-caption alignnone" style="width: 392px"><a href="http://ananthonline.net/wp-content/uploads/2011/08/image001.png"><img class="size-full wp-image-295" title="quenya-parsing.png" src="http://ananthonline.net/wp-content/uploads/2011/08/image001.png" alt="quenya parsing overview" width="382" height="241" /></a><p class="wp-caption-text">Quenya parsing overview</p></div>
<p>But it&#8217;s probably more cumbersome to write an entire parser each time you want to add or modify a single feature of the base grammar you&#8217;re using right? That&#8217;s where the monadic parser written in C# comes in. To illustrate, let&#8217;s take a simple example. We&#8217;ll write a simple parser that can parse words (alphabets) given a string and then extend it to have more features without rewriting the entire parser.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="csharp"><pre class="de1"><span class="co1">// A simpleton parser, one that doesn't understand the . (period) and that will fail if it encounters one.</span>
<span class="kw1">public</span> abstract <span class="kw4">class</span> SimpleSentenceParser<span class="sy0">:</span> CharParsers
<span class="br0">&#123;</span>
    <span class="co1">// Defines the set of all whitespace characters</span>
	<span class="kw1">private</span> Parser _whitespaceChars<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser WhitespaceChars
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _whitespaceChars <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_whitespaceChars <span class="sy0">=</span> <span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">' '</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">'<span class="es0">\t</span>'</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">'<span class="es0">\n</span>'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">'<span class="es0">\r</span>'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// A whitespace is 0 or more repetitions of a valid Whitespace character</span>
	<span class="kw1">private</span> Parser _whitespace<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser Whitespace
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _whitespace <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_whitespace <span class="sy0">=</span> Rep<span class="br0">&#40;</span>WhitespaceChars<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// A word is multiple (alphabetic) characters that are not whitespaces</span>
	<span class="kw1">private</span> Parser _word<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser Word
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _word <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_word <span class="sy0">=</span> <span class="kw1">from</span> w <span class="kw1">in</span> Whitespace
                            <span class="kw1">from</span> c <span class="kw1">in</span> <span class="kw4">Char</span><span class="br0">&#40;</span><span class="kw4">char</span><span class="sy0">.</span><span class="me1">IsLetter</span><span class="br0">&#41;</span>
                            <span class="kw1">from</span> word <span class="kw1">in</span> Rep<span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="kw4">char</span><span class="sy0">.</span><span class="me1">IsLetter</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
                            <span class="kw1">select</span> <span class="kw3">new</span> WordTerm<span class="br0">&#40;</span>word<span class="sy0">.</span><span class="me1">Aggregate</span><span class="br0">&#40;</span><span class="kw3">new</span> <span class="kw4">string</span><span class="br0">&#40;</span><span class="kw3">new</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="br0">&#123;</span>c<span class="br0">&#125;</span><span class="br0">&#41;</span>, <span class="br0">&#40;</span>acc, ch<span class="br0">&#41;</span> <span class="sy0">=&amp;</span>gt<span class="sy0">;</span> acc <span class="sy0">+</span> ch<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// A sentence is a set of words - simplistic, but will work for single sentences</span>
	<span class="kw1">private</span> Parser _sentence<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser Sentence
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _sentence <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_sentence <span class="sy0">=</span> <span class="kw1">from</span> words <span class="kw1">in</span> Rep<span class="br0">&#40;</span>Word<span class="br0">&#41;</span>
                                <span class="kw1">select</span> <span class="kw3">new</span> SentenceTerm<span class="br0">&#40;</span>words<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// Set of all sentences in the input (start symbol for this grammar)</span>
	<span class="kw1">private</span> Parser _all<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser All
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _all <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_all <span class="sy0">=</span> <span class="kw1">from</span> sentence <span class="kw1">in</span> Sentence
                           <span class="kw1">select</span> <span class="br0">&#40;</span>Term<span class="br0">&#41;</span> sentence<span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="co1">// A concrete implementation of the above parser that can accept string input</span>
<span class="kw1">public</span> <span class="kw4">class</span> SimpleSentenceParser<span class="sy0">:</span> SimpleSentenceParser
<span class="br0">&#123;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser AnyChar <span class="co1">// Pick one character at a time</span>
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> input <span class="sy0">=&amp;</span>gt<span class="sy0">;</span> input<span class="sy0">.</span><span class="me1">Length</span> <span class="sy0">&amp;</span>gt<span class="sy0">;</span> <span class="nu0">0</span> <span class="sy0">?</span> 
				<span class="kw3">new</span> Result<span class="br0">&#40;</span>input<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>, input<span class="sy0">.</span><span class="me1">Substring</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">:</span> 
				<span class="kw1">null</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Note that the code above is quite readable (as a grammar) due to the use of C# query expressions. Now let&#8217;s look at a parser that &#8220;extends&#8221; the capabilities of this parser.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="csharp"><pre class="de1"><span class="co1">// A slightly more intelligent parser, it can identify sentences properly</span>
<span class="co1">// Note that this parser does NOT redefine what a word means. It only redefines a sentence.</span>
<span class="kw1">public</span> abstract <span class="kw4">class</span> BetterSentenceParser<span class="sy0">:</span> SimpleSentenceParser
<span class="br0">&#123;</span>
    <span class="kw1">private</span> Parser _whitespaceChars<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser WhitespaceChars <span class="co1">// Adds to existing whitespace characters</span>
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _whitespaceChars <span class="sy0">??</span>
                <span class="br0">&#40;</span>_whitespaceChars <span class="sy0">=</span> <span class="kw1">base</span><span class="sy0">.</span><span class="me1">WhitespaceChars</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">','</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">';'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// New, defines sentence terminators to allow this parser to understand them</span>
	<span class="kw1">private</span> Parser _sentenceTerminators<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser SentenceTerminators
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _sentenceTerminators <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_sentenceTerminators <span class="sy0">=</span> <span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">'.'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// Redefines what a sentence means and takes sentence terminators</span>
	<span class="co1">// into account</span>
	<span class="kw1">private</span> Parser _sentence<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser Sentence
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _sentence <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_sentence <span class="sy0">=</span> <span class="kw1">from</span> words <span class="kw1">in</span> Rep<span class="br0">&#40;</span>Word<span class="br0">&#41;</span>
                                <span class="kw1">from</span> terminator <span class="kw1">in</span> SentenceTerminators
                                <span class="kw1">select</span> <span class="kw3">new</span> SentenceTerm<span class="br0">&#40;</span>words<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// This now returns multiple sentences</span>
	<span class="kw1">private</span> Parser _all<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser All <span class="co1">// Actually selects multiple sentences</span>
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _all <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_all <span class="sy0">=</span> <span class="kw1">from</span> sentences <span class="kw1">in</span> Rep<span class="br0">&#40;</span>Sentence<span class="br0">&#41;</span>
                           <span class="kw1">select</span> <span class="br0">&#40;</span>Term<span class="br0">&#41;</span><span class="kw3">new</span> ParagraphTerm<span class="br0">&#40;</span>sentences<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="co1">// A concrete implementation of a parser that can accept string input</span>
<span class="kw1">public</span> <span class="kw4">class</span> BetterSentenceParser <span class="sy0">:</span> BetterSentenceParser
<span class="br0">&#123;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser AnyChar
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> input <span class="sy0">=&amp;</span>gt<span class="sy0">;</span> input<span class="sy0">.</span><span class="me1">Length</span> <span class="sy0">&amp;</span>gt<span class="sy0">;</span> <span class="nu0">0</span> <span class="sy0">?</span> <span class="kw3">new</span> Result<span class="br0">&#40;</span>input<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>, input<span class="sy0">.</span><span class="me1">Substring</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">:</span> <span class="kw1">null</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Ah, that looks fairly simple! The observant among you no doubt noticed that this parser extends (Sentence) and modifies existing behavior (WhitespaceChars) without having to do all the work by itself. Using the concrete version of these two parsers, we can now parse stuff!</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="csharp"><pre class="de1"><span class="kw1">internal</span> <span class="kw4">class</span> Program
<span class="br0">&#123;</span>
    <span class="kw1">private</span> <span class="kw1">const</span> <span class="kw4">string</span> SimpleText <span class="sy0">=</span> <span class="st_h">@&quot;Lorem ipsum dolor sit amet&quot;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">private</span> <span class="kw1">const</span> <span class="kw4">string</span> ComplexText <span class="sy0">=</span>
        <span class="st_h">@&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus enim lorem,&quot;</span> <span class="sy0">+</span>
        <span class="st_h">@&quot; tincidunt ac sollicitudin fringilla, vulputate a dolor. Sed eu viverra ligula.&quot;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">private</span> <span class="kw1">static</span> <span class="kw4">void</span> Main<span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#91;</span><span class="br0">&#93;</span> args<span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="co1">// Will parse SimpleText into multiple words and one sentence</span>
		<span class="br0">&#123;</span>
			var parser <span class="sy0">=</span> <span class="kw3">new</span> SimpleSentenceParser<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			var result <span class="sy0">=</span> parser<span class="sy0">.</span><span class="me1">All</span> <span class="br0">&#40;</span>SimpleText<span class="br0">&#41;</span><span class="sy0">;</span>
		<span class="br0">&#125;</span>
&nbsp;
        <span class="co1">// Will parse ComplexText partially, fail when it encounters the '.'</span>
		<span class="br0">&#123;</span>
			var parser <span class="sy0">=</span> <span class="kw3">new</span> SimpleSentenceParser<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			var result <span class="sy0">=</span> parser<span class="sy0">.</span><span class="me1">All</span> <span class="br0">&#40;</span>ComplexText<span class="br0">&#41;</span><span class="sy0">;</span>
		<span class="br0">&#125;</span>
&nbsp;
        <span class="co1">// Will parse ComplexText into multiple words and multiple sentences</span>
		<span class="br0">&#123;</span>
			var parser <span class="sy0">=</span> <span class="kw3">new</span> ComplexSentenceParser<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			var result <span class="sy0">=</span> parser<span class="sy0">.</span><span class="me1">All</span> <span class="br0">&#40;</span>ComplexText<span class="br0">&#41;</span><span class="sy0">;</span>
		<span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Let&#8217;s now extend this concept given a fully functional C# parser definition. The user will now be able to &#8220;modify&#8221; the syntax of the language by defining his own parser that changes certain productions and/or terminals in the grammar. Add in a mechanism to link a given source file to a given grammar/parser (attribute on the parser = file extension of source) and you have Quenya, a language that encourages people to define and modify it.</p>
<p>Granted, this is probably tougher than just learning one language, but considering that the code you write using your DSL or modified base language will be much, much more suited to your purposes (if you use it wisely) and that most of your code will be written in the straight-up base grammar for your language makes this worth it (to me, at least &#8211; I&#8217;d be happy to hear your thought/comments). Also, people who don&#8217;t care about language extensibility can just use a vanilla grammar for the language of their choice and continue doing what they&#8217;ve been doing.</p>
<p>The next post on Quenya will deal with the implications of a language like this and how it can be used (or abused) in a real context.</p>
<p>Download the source code here: <a href="http://ananthonline.net/wp-content/uploads/2011/08/QuenyaParsing.zip">QuenyaParsing</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2011/08/04/quenya-beyond-syntax/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>OpenCL.Net published!</title>
		<link>http://ananthonline.net/2010/07/20/opencl-net-published/</link>
		<comments>http://ananthonline.net/2010/07/20/opencl-net-published/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 13:20:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[OpenCL]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/general/opencl-net-published</guid>
		<description><![CDATA[ Tweet <p>I just published my version of .NET bindings for OpenCL over on Codeplex last night. Why another, you ask? There’s already so many out there … Cloo, OpenCL.NET from hoopoe and another OpenCL.Net over at Sourceforge (and more?). Well, …</p> Every API out there has an object-oriented version of the API that’s easily [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F07%2F20%2Fopencl-net-published%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/07/20/opencl-net-published/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/07/20/opencl-net-published/"  data-text="OpenCL.Net published!" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/07/20/opencl-net-published/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>I just published my version of <a href="http://openclnet.codeplex.com/">.NET bindings for OpenCL</a> over on Codeplex last night. Why another, you ask? There’s already so many out there … <a href="http://www.opentk.com/project/cloo">Cloo</a>, <a href="http://www.hoopoe-cloud.com/Solutions/OpenCL.NET/Default.aspx">OpenCL.NET from hoopoe</a> and another <a href="http://sourceforge.net/projects/openclnet/">OpenCL.Net over at Sourceforge</a> (and more?). Well, …</p>
<ul>
<li>Every API out there has an object-oriented version of the API that’s easily usable from .NET. Sure, it’s easy … but looks very different from the raw OpenCL API if I wanted to use it, right? There’s reason #1 right there. I wanted a set of .NET bindings that look, feel and act like the C-style API so I (read: the users) could port existing samples or read books/tutorials and understand what’s going on.</li>
<li>Which brings us to our second question: Don’t all of the mentioned bindings also have the C-style API exposed? Sure, they do. But some of them mark the exposed API as unsafe, use of which would force users to mark their own projects as unsafe too. Secondly, every set of bindings I saw had raw translations of the API transliterating &lt;anything&gt;* to IntPtr (and others along those lines) meaning we have to use their OO abstractions to get anything done easily. I wanted something more .NET friendly at the API level, however.</li>
</ul>
<p>So I guess the reason I wrote my own bindings is: I wanted to strike the middle ground between OO + .NET friendly and raw API translation. You can find this over at <a href="http://openclnet.codeplex.com/">Codeplex</a>. The API isn’t complete yet, but some things I’m particularly happy about are:</p>
<ol>
<li>No unsafe code (yet).</li>
<li>Everything is .NET friendly AND you can use it as you would the raw API (overloads).</li>
<li>As little explicit marshaling as possible, in fact all the exposed methods that invoke the extern’d methods in OpenCL.dll are only one call/line.</li>
</ol>
<p>Initially, I started with these bindings for my project <a href="http://brahma.ananthonline.net">Brahma</a>, but decided it was a large enough effort to put up separately. I hope people find it useful alongside the other tools for OpenCL for .NET that are already available. I hope to have the API completed and released soon. Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/07/20/opencl-net-published/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Parsing command line arguments with C# &amp; LINQ</title>
		<link>http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/</link>
		<comments>http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 01:39:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/dotnet/parsing-command-line-arguments-with-c-linq/</guid>
		<description><![CDATA[ Tweet <p>Whenever I sit down to write an application (mostly a console application), I find myself wishing I had some code I could just drop in to parse command line arguments with. A friend of mine has authored the excellent ConsoleFX library, and it&#8217;s really good if you want to do heavy processing, validations [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F07%2F02%2Fparsing-command-line-arguments-with-c-linq%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/"  data-text="Parsing command line arguments with C# &#038; LINQ" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Whenever I sit down to write an application (mostly a console application), I find myself wishing I had some code I could just drop in to parse command line arguments with. A friend of mine has authored the excellent ConsoleFX library, and it&#8217;s really good if you want to do heavy processing, validations and complex command line argument structures with help. Most of the time, however, I don&#8217;t.</p>
<p>So I spent the better part of my evening writing something that I hope I will be able to carry around as a code snippet small enough to use anytime, anywhere in an elegant fashion.</p>
<pre class="csharp" style="background-color: #ffffff; font-family: consolas, monospace; font-size: small;">
<ol>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008080;">#region CommandLine</span></div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #0600ff; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> CommandLine</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> <span style="color: #0600ff; font-weight: bold;">Switch</span> <span style="font-style: italic; color: #008080;">// Class that encapsulates switch data. Not meant for direct use.</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span> name, Action<span style="color: #008000;">&lt;</span>IEnumerable<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;&gt;</span> handler, <span style="color: #6666cc; font-weight: bold;">string</span> shortForm <span style="color: #008000;">=</span> <span style="color: #0600ff; font-weight: bold;">null</span><span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			Name <span style="color: #008000;">=</span> name<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			Handler <span style="color: #008000;">=</span> handler<span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			ShortForm <span style="color: #008000;">=</span> shortForm<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Name</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			get<span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			<span style="color: #0600ff; font-weight: bold;">private</span> set<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> ShortForm</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			get<span style="color: #008000;">;</span> <span style="color: #0600ff; font-weight: bold;">private</span> set<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> Action<span style="color: #008000;">&lt;</span>IEnumerable<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;&gt;</span> Handler</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			get<span style="color: #008000;">;</span> <span style="color: #0600ff; font-weight: bold;">private</span> set<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> InvokeHandler<span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">[</span><span style="color: #008000;">]</span> values<span style="color: #008000;">)</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			Handler<span style="color: #008000;">(</span>values<span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			<span style="color: #0600ff; font-weight: bold;">return</span> <span style="color: #ff0000;">1</span><span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">}</span></div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="font-style: italic; color: #008080;">// The regex that extracts names and comma-separated values for switches </span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="font-style: italic; color: #008080;">// in the form (&lt;switch&gt;[:value,value,value])+</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">private</span> <span style="color: #0600ff; font-weight: bold;">static</span> <span style="color: #0600ff; font-weight: bold;">readonly</span> Regex _regex <span style="color: #008000;">=</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">(</span><span style="color: #666666;">@"s*(?&lt;switch&gt;(?&lt;name&gt;w+)(:s*(?&lt;value&gt;w+(s*,s*w+)*))?)"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">Compiled</span> <span style="color: #008000;">|</span> RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">CultureInvariant</span> <span style="color: #008000;">|</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">ExplicitCapture</span> <span style="color: #008000;">|</span> RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">IgnoreCase</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">private</span> <span style="color: #0600ff; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> NameGroup <span style="color: #008000;">=</span> <span style="color: #666666;">"name"</span><span style="color: #008000;">;</span> <span style="font-style: italic; color: #008080;">// Names of capture groups</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">private</span> <span style="color: #0600ff; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> ValueGroup <span style="color: #008000;">=</span> <span style="color: #666666;">"value"</span><span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #0600ff; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Process<span style="color: #008000;">(</span><span style="color: #0600ff; font-weight: bold;">this</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">[</span><span style="color: #008000;">]</span> args, Action printUsage, <span style="color: #0600ff; font-weight: bold;">params</span> <span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">[</span><span style="color: #008000;">]</span> switches<span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// Run through all matches in the concatenated argument list and if any</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// of the switches match, get the values and invoke the handler we were</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// given. We do a Sum() here for 2 reasons; a) To actually run the handlers</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// and b) see if any were invoked at all (each returns 1 if invoked).</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// If none were invoked, we simply invoke the printUsage handler.</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">if</span> <span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0600ff; font-weight: bold;">from</span> Match match <span style="color: #0600ff; font-weight: bold;">in</span> _regex<span style="color: #008000;">.</span><span style="color: #0000ff;">Matches</span><span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, args<span style="color: #008000;">)</span><span style="color: #008000;">)</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			 <span style="color: #0600ff; font-weight: bold;">from</span> arg <span style="color: #0600ff; font-weight: bold;">in</span> switches</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			 <span style="color: #0600ff; font-weight: bold;">where</span> match<span style="color: #008000;">.</span><span style="color: #0000ff;">Success</span> <span style="color: #008000;">&amp;&amp;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">				   <span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Compare</span><span style="color: #008000;">(</span>match<span style="color: #008000;">.</span><span style="color: #0000ff;">Groups</span><span style="color: #008000;">[</span>NameGroup<span style="color: #008000;">]</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Value</span>, arg<span style="color: #008000;">.</span><span style="color: #0000ff;">Name</span>, <span style="color: #0600ff; font-weight: bold;">true</span><span style="color: #008000;">)</span> <span style="color: #008000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #008000;">)</span> <span style="color: #008000;">||</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">					<span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Compare</span><span style="color: #008000;">(</span>match<span style="color: #008000;">.</span><span style="color: #0000ff;">Groups</span><span style="color: #008000;">[</span>NameGroup<span style="color: #008000;">]</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Value</span>, arg<span style="color: #008000;">.</span><span style="color: #0000ff;">ShortForm</span>, <span style="color: #0600ff; font-weight: bold;">true</span><span style="color: #008000;">)</span> <span style="color: #008000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			 <span style="color: #0600ff; font-weight: bold;">select</span> arg<span style="color: #008000;">.</span><span style="color: #0000ff;">InvokeHandler</span><span style="color: #008000;">(</span>match<span style="color: #008000;">.</span><span style="color: #0000ff;">Groups</span><span style="color: #008000;">[</span>ValueGroup<span style="color: #008000;">]</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Value</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Split</span><span style="color: #008000;">(</span><span style="color: #666666;">','</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Sum</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			printUsage<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span> <span style="font-style: italic; color: #008080;">// We didn't find any switches</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">}</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008080;">#endregion</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
</ol>
</pre>
<p>All of the magic happens inside the Process method, where the query tries to match the arguments against the ones we want to check for. The .Sum() aggregate method does two things.</p>
<ol>
<li>It enumerates the elements of the IQueryable, actually calling the handlers in the process. Nothing happens till then!</li>
<li>Each of the InvokeHandler calls returns 1, so the result of the .Sum() is 0 if there were no matches (which is when we call the supplied printUsage handler).</li>
</ol>
<p>Neat, huh? Using it is even simpler!</p>
<pre class="csharp" style="background-color: #ffffff; font-family: consolas, monospace; font-size: x-small;">
<ol>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">            args<span style="color: #008000;">.</span><span style="color: #0000ff;">Process</span><span style="color: #008000;">(</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"Usage is switch0:value switch:value switch2"</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandLine<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch0"</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                    val <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch 0 with value {0}"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, val<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandLine<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch1"</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                    val <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch 1 with value {0}"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, val<span style="color: #008000;">)</span><span style="color: #008000;">)</span>, <span style="color: #666666;">"s1"</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandLine<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch2"</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                    val <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch 2 with value {0}"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, val<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">        <span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
</ol>
</pre>
<p>Any handlers you provide will be called for each switch or it&#8217;s shortform(if found, of course). Now get started writing those fantastic console applications.</p>
<p>Obligatory disclaimer and <a href="http://sam.zoy.org/wtfpl/">License</a>: The code above is for you to do whatever you want to. Even if it blows you up (like <a href="http://www.youtube.com/watch?v=OKTlkG5CdF4&amp;feature=related">Dr. Manhattan blows Rorschach up</a>), don&#8217;t come back from the dead to haunt me. I would, however appreciate it if you kept the comment attributing that code to me.</p>
<div id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:3e53c8a2-e654-480f-ae95-ad957ca154c8" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<div id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:3e53c8a2-e654-480f-ae95-ad957ca154c8" class="wlWriterSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<p>Double Edit: Modified the Regex so it can accept quoted parameters (even filenames).</p>
<div id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:681f230e-9598-44dd-bdb7-aca9b5c7fcb1" class="wlWriterSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<p>Download the code snippet from the <a href="http://www.ananthonline.net/code-snippets" target="_self">code snippets page</a>.</p>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Interview up on DotNetRocks!</title>
		<link>http://ananthonline.net/2009/07/23/interview-up-on-dotnetrocks/</link>
		<comments>http://ananthonline.net/2009/07/23/interview-up-on-dotnetrocks/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 13:50:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Brahma]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=40</guid>
		<description><![CDATA[ Tweet <p>My interview about Brahma is up on DotNetRocks, you can find it here. I hope this helps Brahma&#8217;s popularity and remember, contributions are most welcome (samples, help getting Brahma to run on Mono on Linux)!</p> <p>I&#8217;ve recently had a new idea, the concept of using user-defined types with Brahma. This should (hopefully) be [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2009%2F07%2F23%2Finterview-up-on-dotnetrocks%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2009/07/23/interview-up-on-dotnetrocks/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2009/07/23/interview-up-on-dotnetrocks/"  data-text="Interview up on DotNetRocks!" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2009/07/23/interview-up-on-dotnetrocks/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>My interview about Brahma is up on DotNetRocks, you can find it <a href="http://www.dotnetrocks.com/default.aspx?showNum=466">here</a>. I hope this helps Brahma&#8217;s popularity and remember, contributions are most welcome (samples, help getting Brahma to run on Mono on Linux)!</p>
<p>I&#8217;ve recently had a new idea, the concept of using user-defined types with Brahma. This should (hopefully) be out soon! Look out!</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2009/07/23/interview-up-on-dotnetrocks/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Pin and Un-pin items to/from the Windows 7 taskbar</title>
		<link>http://ananthonline.net/2009/06/17/pin-and-un-pin-items-tofrom-the-windows-7-taskbar/</link>
		<comments>http://ananthonline.net/2009/06/17/pin-and-un-pin-items-tofrom-the-windows-7-taskbar/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 06:26:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=37</guid>
		<description><![CDATA[ Tweet <p>One of the things I wanted to do with Lyre (my Windows 7 taskbar-based MP3 player), was to</p> Figure out if a given executable is pinned to the taskbar Un-pin it from the taskbar Pin it back to the taskbar <p>During my searches, I found this blog post that says programmatic access to [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2009%2F06%2F17%2Fpin-and-un-pin-items-tofrom-the-windows-7-taskbar%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2009/06/17/pin-and-un-pin-items-tofrom-the-windows-7-taskbar/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2009/06/17/pin-and-un-pin-items-tofrom-the-windows-7-taskbar/"  data-text="Pin and Un-pin items to/from the Windows 7 taskbar" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2009/06/17/pin-and-un-pin-items-tofrom-the-windows-7-taskbar/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>One of the things I wanted to do with <a href="http://blog.ananthonline.net/?p=36">Lyre</a> (my Windows 7 taskbar-based MP3 player), was to</p>
<ol>
<li>Figure out if a given executable is pinned to the taskbar</li>
<li>Un-pin it from the taskbar</li>
<li>Pin it back to the taskbar</li>
</ol>
<p>During my searches, I found <a href="http://blogs.technet.com/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx">this</a> blog post that says programmatic access to pinning and un-pinning has been disabled for a similar reason. I did find a couple of posts <a href="http://cs.axvius.com/blogs/aaron/archive/2009/02/19/script-to-pin-item-to-taskbar-or-start-menu-in-windows-7.aspx">here</a> and <a href="http://blogs.technet.com/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx">here</a>, showing how to use a small shell script to pin and un-pin items.</p>
<p>The idea is rather simple, really. The verbs &#8220;<em>Pin to Tas&amp;kbar</em>&#8221; and &#8220;<em>Unpin from Tas&amp;kbar</em>&#8221; (the ampersand is the shortcut, it is required to directly execute the verb) are available on a shell link object. Executing one or the other will pin/unpin the specified shortcut.</p>
<p>How do we find out if an item is pinned to the taskbar? For that, we need to look in &#8220;%appdata%MicrosoftInternet ExplorerQuick LaunchUser PinnedTaskBar&#8221;, where these pinned &#8220;shortcuts&#8221; live. If we find a particular executable&#8217;s shortcut there, that means it&#8217;s pinned.</p>
<p>Now that we know what we need to do, the doing is quite simple, really.</p>
<h2></h2>
<h4>Tell if a shortcut is pinned to the taskbar</h4>
<ol>
<li>Examine each shortcut in the user&#8217;s pinned items path.</li>
<li>If the path (or filename?) matches the executable you&#8217;re looking for, return true.</li>
<li>Otherwise return false.</li>
</ol>
<h4 style="width: 279px; height: 19px">Pin/Unpin items to/from the taskbar</h4>
<ol>
<li>Create a temporary shortcut to the executable we want to pin/unpin</li>
<li>Create and execute a shell script that runs the appropriate verb (&#8220;<em>Pin to Tas&amp;kbar</em>&#8221; or &#8220;<em>Unpin from Tas&amp;kbar</em>&#8220;)</li>
<li>We&#8217;re done!</li>
</ol>
<p><a href="http://blog.ananthonline.net/wp-content/uploads/2009/06/windows7taskbarextensions.zip" title="Windows7TaskbarExtensions.zip">Attached</a> is a single .cs file that contains a class called Windows7TaskbarExtensions.cs.</p>
<h6><font color="#808080">Note: I&#8217;ve used the </font><a href="http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp"><font color="#808080">ShellShortcut</font></a><font color="#808080"> classes by Mattias Sjögren </font></h6>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2009/06/17/pin-and-un-pin-items-tofrom-the-windows-7-taskbar/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Lyre – A Windows 7 music player</title>
		<link>http://ananthonline.net/2009/05/18/lyre-a-windows-7-music-player/</link>
		<comments>http://ananthonline.net/2009/05/18/lyre-a-windows-7-music-player/#comments</comments>
		<pubDate>Mon, 18 May 2009 13:35:24 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=36</guid>
		<description><![CDATA[ Tweet <p>What does Windows 7 have to do with music? Nothing, really. But I&#8217;ve noticed that no one has been enterprising enough to put the Window 7 taskbar features to REALLY good use and make an mp3 player that we can use while we work (WMP team, are you listening?). I mean, who doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2009%2F05%2F18%2Flyre-a-windows-7-music-player%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2009/05/18/lyre-a-windows-7-music-player/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2009/05/18/lyre-a-windows-7-music-player/"  data-text="Lyre – A Windows 7 music player" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2009/05/18/lyre-a-windows-7-music-player/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>What does Windows 7 have to do with music? Nothing, really. But I&#8217;ve noticed that no one has been enterprising enough to put the Window 7 taskbar features to REALLY good use and make an mp3 player that we can use while we work (WMP team, are you listening?). I mean, who doesn&#8217;t listen to music while working? Everyone who raised their hands can leave the room now. Just kidding.</p>
<p>Onto the good stuff. Lyre sits in your taskbar, updates the application icon with the album art (if present), shows play progress on the taskbar button and provides all the basic play controls as thumb-buttons on the taskbar. There are no visualizations yet, but they should be easy enough to do if there&#8217;s enough demand for it. Here are some screenshots:</p>
<p><a href="http://blog.ananthonline.net/wp-content/uploads/2009/05/thumbnailcontrols.jpg"><img src="http://blog.ananthonline.net/wp-content/uploads/2009/05/thumbnailcontrols-thumb.jpg" style="border-width: 0px; display: inline" title="Thumbnail&amp;Controls" alt="Thumbnail&amp;Controls" border="0" height="244" width="232" /></a></p>
<p>Here&#8217;s the player with controls, progress and tag-reading.</p>
<p><a href="http://blog.ananthonline.net/wp-content/uploads/2009/05/jumplist.jpg"><img src="http://blog.ananthonline.net/wp-content/uploads/2009/05/jumplist-thumb.jpg" style="border-width: 0px; display: inline" title="Jumplist" alt="Jumplist" border="0" height="244" width="226" /></a></p>
<p>You can control the player by using it&#8217;s jump list.</p>
<p>True, this project only took me a week to complete (to this level), but there were a lot of unknowns and problems with the managed Windows7 integration wrapper. Well, I guess I should write a blog post on those later <img src='http://ananthonline.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Download it here, give it a whirl and let me know what you think.</p>
<p style="margin: 0px; padding: 0px; display: inline; float: none" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:388c032c-fa4e-4155-bfd4-d807fb305896" class="wlWriterEditableSmartContent"><a href="http://blog.ananthonline.net/wp-content/uploads/2009/05/lyresetup.zip" target="_self">Lyre-setup.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2009/05/18/lyre-a-windows-7-music-player/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Brahma on Mono!</title>
		<link>http://ananthonline.net/2008/10/23/brahma-on-mono/</link>
		<comments>http://ananthonline.net/2008/10/23/brahma-on-mono/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 12:43:08 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Brahma]]></category>
		<category><![CDATA[GPGPU]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=25</guid>
		<description><![CDATA[ Tweet <p>Brahma now runs on Mono! Here is a screenshot of the Mandelbrot sample running under Mono (on Windows, at the moment). I&#8217;m trying to get it working on Linux, but I haven&#8217;t been able to get MonoDevelop up on my PCLinuxOS, so I&#8217;m stuck with an empty X11Context implementation.</p> <p>Any help working with [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2008%2F10%2F23%2Fbrahma-on-mono%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2008/10/23/brahma-on-mono/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2008/10/23/brahma-on-mono/"  data-text="Brahma on Mono!" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2008/10/23/brahma-on-mono/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Brahma now runs on Mono! Here is a screenshot of the Mandelbrot sample running under Mono (on Windows, at the moment). I&#8217;m trying to get it working on Linux, but I haven&#8217;t been able to get MonoDevelop up on my PCLinuxOS, so I&#8217;m stuck with an empty X11Context implementation.</p>
<p>Any help working with Mono on Linux would be appreciated, please give me a holler.</p>
<p>Yippeeeee!</p>
<p><a href="http://blog.ananthonline.net/wp-content/uploads/2008/10/mandelbrot-mono-windows.jpg" target="_blank"><img src="http://blog.ananthonline.net/wp-content/uploads/2008/10/mandelbrot-mono-windows-thumb.jpg" style="border: 0px none " alt="Mandelbrot-Mono-Windows" border="0" height="122" width="118" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2008/10/23/brahma-on-mono/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Markup extensions in Xoml</title>
		<link>http://ananthonline.net/2008/05/04/markup-extensions-in-xoml/</link>
		<comments>http://ananthonline.net/2008/05/04/markup-extensions-in-xoml/#comments</comments>
		<pubDate>Sun, 04 May 2008 17:06:49 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Xaml]]></category>
		<category><![CDATA[Xoml]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=19</guid>
		<description><![CDATA[ Tweet <p>One of the features I spent a lot of time thinking about, and implementing are: &#8220;deferred&#8221; ProvideValue calls on MarkupExtensions. In a XAML markup extension, ProvideValue is called when the tree is being loaded, and sometimes, it may be impossible to provide a value at that time. Also, since XAML makes use of [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2008%2F05%2F04%2Fmarkup-extensions-in-xoml%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2008/05/04/markup-extensions-in-xoml/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2008/05/04/markup-extensions-in-xoml/"  data-text="Markup extensions in Xoml" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2008/05/04/markup-extensions-in-xoml/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>One of the features I spent a lot of time thinking about, and implementing are: &#8220;deferred&#8221; ProvideValue calls on MarkupExtensions. In a XAML markup extension, ProvideValue is called when the tree is being loaded, and sometimes, it may be impossible to provide a value at that time. Also, since XAML makes use of internal classes like ResourceReferenceExpression (along with some other quirks like requiring derivation from FrameworkElement. More on this <a href="http://blog.ananthonline.net/?p=7" target="_blank">here</a>), it becomes quite a messy task resolving these references and values later.</p>
<p>In Xoml, however, every markup extension can tell XomlLoader to defer<em> </em>its ProvideValue call, by setting defer to true.</p>
<blockquote><p><span style="font-size: 8pt; color: blue; line-height: 115%; font-family: consolas">public</span><span style="font-size: 8pt; color: black; line-height: 115%; font-family: consolas"> </span><span style="font-size: 8pt; color: blue; line-height: 115%; font-family: consolas">abstract</span><span style="font-size: 8pt; color: black; line-height: 115%; font-family: consolas"> </span><span style="font-size: 8pt; color: blue; line-height: 115%; font-family: consolas">object</span><span style="font-size: 8pt; color: black; line-height: 115%; font-family: consolas"> ProvideValue(</span><span style="font-size: 8pt; color: blue; line-height: 115%; font-family: consolas">object</span><span style="font-size: 8pt; color: black; line-height: 115%; font-family: consolas"> context, </span><span style="font-size: 8pt; color: #2b91af; line-height: 115%; font-family: consolas">PropertyInfo</span><span style="font-size: 8pt; color: black; line-height: 115%; font-family: consolas"> property, </span><span style="font-size: 8pt; color: blue; line-height: 115%; font-family: consolas">out</span><span style="font-size: 8pt; color: black; line-height: 115%; font-family: consolas"> </span><span style="font-size: 8pt; color: blue; line-height: 115%; font-family: consolas">bool</span><span style="font-size: 8pt; color: black; line-height: 115%; font-family: consolas"> defer);</span></p></blockquote>
<p>Of course, at this point the markup extension is also expected to provide a default value, one that can be assigned to the context without errors. It is important to remember that the &#8220;context&#8221; can also be other markup extensions, in the case of a nested sub-expression.</p>
<p>After the entire object tree has been loaded, DeferredProvideValue</p>
<blockquote><p><span style="color: blue">public</span> <span style="color: blue">virtual</span> <span style="color: blue">object</span> DeferredProvideValue(<span style="color: blue">object</span> root, <span style="color: blue">object</span> context, <span style="color: #2b91af">PropertyInfo</span> property)</p></blockquote>
<p>is called once for each ProvideValue call that was deferred. Since the tree has been loaded now, the partially-initialized(?) root object is also passed in. XomlLoader then calls the OnAfterLoad method on each markup extension that was found.</p>
<blockquote>
<p style="background: white none repeat scroll 0% 50%; font-size: 8pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: consolas">
<p style="margin: 0px"><span style="color: blue">protected</span> <span style="color: blue">internal</span> <span style="color: blue">virtual</span> <span style="color: blue">void</span> OnAfterLoad(<span style="color: #2b91af">AfterLoadEventArgs</span> e)</p>
</blockquote>
<p>This calling order is undefined, and extensions that have not been used in the currently loaded XOML are not called upon for OnAfterLoad processing. OnAfterLoad is called exactly once for each type of extension, its calling order is undefined. Like DeferredProvideValue, the root of the tree is provided to this method. The difference here, however is that OnAfterLoad can return a <em>different</em> object back to XomlLoader (through AfterLoadEventArgs), thus changing the whole tree! I&#8217;m not sure if this is an irresponsible thing to do, I thought it might help do radical things to the object tree and make it more extensible.</p>
<p>I would love to hear your thoughts on the features I&#8217;ve currently implemented, and future directions for development.</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2008/05/04/markup-extensions-in-xoml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>XOML on CodePlex</title>
		<link>http://ananthonline.net/2008/05/04/xoml-on-codeplex/</link>
		<comments>http://ananthonline.net/2008/05/04/xoml-on-codeplex/#comments</comments>
		<pubDate>Sun, 04 May 2008 17:04:50 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Xoml]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=18</guid>
		<description><![CDATA[ Tweet <p>I&#8217;ve had the XOML project registered on CodePlex since my last post, but it is now published. An early 0.1 pre-release version is also available. This version allows you to load hand-written Xoml, although XomlWriter isn&#8217;t far behind.</p> <p>To get stared with Xoml, the unit tests are probably the best place to start [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2008%2F05%2F04%2Fxoml-on-codeplex%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2008/05/04/xoml-on-codeplex/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2008/05/04/xoml-on-codeplex/"  data-text="XOML on CodePlex" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2008/05/04/xoml-on-codeplex/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>I&#8217;ve had the XOML project registered on CodePlex since my last post, but it is now <a href="http://codeplex.com/xoml" target="_blank">published</a>. An early <a href="http://www.codeplex.com/xoml/Release/ProjectReleases.aspx?ReleaseId=13027" target="_blank">0.1 pre-release</a> version is also available. This version allows you to load hand-written Xoml, although XomlWriter isn&#8217;t far behind.</p>
<p>To get stared with Xoml, the unit tests are probably the best place to start poking around. Feel free to contact me with comments and/or suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2008/05/04/xoml-on-codeplex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XAML without WPF = XOML</title>
		<link>http://ananthonline.net/2008/04/13/xaml-without-wpf-xoml/</link>
		<comments>http://ananthonline.net/2008/04/13/xaml-without-wpf-xoml/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 22:58:16 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Xaml]]></category>
		<category><![CDATA[Xoml]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=16</guid>
		<description><![CDATA[ Tweet <p>For a long time, I&#8217;ve been writing about how messed up Xaml is because of WPF-interdependency, and how Microsoft should have decoupled the Xaml bits from WPF, etc (Some of these rants were on my old blog). Well, I finally decided to do something about it, and I&#8217;m writing a XAML-like library that [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2008%2F04%2F13%2Fxaml-without-wpf-xoml%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2008/04/13/xaml-without-wpf-xoml/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2008/04/13/xaml-without-wpf-xoml/"  data-text="XAML without WPF = XOML" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2008/04/13/xaml-without-wpf-xoml/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>For a long time, I&#8217;ve been writing about how messed up Xaml is because of WPF-interdependency, and how Microsoft should have decoupled the Xaml bits from WPF, etc (Some of these rants were on my old blog). Well, I finally decided to <em>do</em> something about it, and I&#8217;m writing a XAML-like library that loads, and writes markup using its own XomlLoader and XomlWriter. At this point I&#8217;m calling the markup e<strong>X</strong>tensible <strong>O</strong>bject <strong>M</strong>arkup <strong>L</strong>anguage (I know that the Workflow Foundations&#8217; designer files have that extension&#8230;) because that&#8217;s what its meant to be. It is also aimed to run on the .NET Framework, Mono and the .NET CF. <img src='http://ananthonline.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Using Xoml, you will be able to data-bind, forward reference, resource reference, write markup-extensions and more. I will be putting this project up for download shortly, look out for more news on it.</p>
<p>PS: If there&#8217;s enough interest, it will have its own mini-site here!</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2008/04/13/xaml-without-wpf-xoml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

