<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div></div><div><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Tilman Bender</div><div>Student des Software Engineering</div><div>Hochschule Heilbronn</div><div><a href="mailto:tbender@stud.hs-heilbronn.de">tbender@stud.hs-heilbronn.de</a></div><div><br></div></div></span><br class="Apple-interchange-newline"> </div><br><div><div>Am 09.04.2009 um 13:35 schrieb Tilman Bender:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi there,<div><br></div><div>I am still playing with my interpreter for arithmetic expressions.</div><div>Now I would like to work with mixed expressions containing integer and floating point numbers.</div><div><br></div><div>When doing so I would like to have the integers automatically "uppercasted" when</div><div>they occur in an expression together with floats.&nbsp;</div><div><br></div><div>So what I currently do is, that I have a Java class providing methods for the respective</div><div>arithmetic operations and invoke it from my interpreter:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp;^(MINUS a=<span style="color: #004080">expr</span> b=<span style="color: #004080">expr</span>)&nbsp; { <span style="color: #0000c0">$value</span> = Arithmetic.subtract(<span style="color: #0000c0">$a</span>.value,<span style="color: #0000c0">$b</span>.value);}</div></div><div><br></div><div>In the add-method I check for the type of the parameters passed in and do the conversion&nbsp;</div><div>to BigDecimal magic.</div><div><br></div><div>However I would like to make this "implicit uppercast" independant from the host language for</div><div>my interpreter to minimize the amount of code I have to change, when switching the host language.&nbsp;</div><div><br></div><div>Has anyone already done such a thing via a TreeWalker?</div><div><br></div><div><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Tilman Bender</div><div>Student des Software Engineering</div><div>Hochschule Heilbronn</div><div><a href="mailto:tbender@stud.hs-heilbronn.de">tbender@stud.hs-heilbronn.de</a></div><div><br></div></div></span><br class="Apple-interchange-newline"> </div><br></div></div><br>List: <a href="http://www.antlr.org/mailman/listinfo/antlr-interest">http://www.antlr.org/mailman/listinfo/antlr-interest</a><br>Unsubscribe: <a href="http://www.antlr.org/mailman/options/antlr-interest/your-email-address">http://www.antlr.org/mailman/options/antlr-interest/your-email-address</a><br></blockquote></div><br></div></body></html>