|
Bay Six Software Beyond the Basics
|
View previous topic :: View next topic |
Author |
Message |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Aug 11th, 2014, 4:44pm Post subject: Experiment - Better string literals? |
|
|
I was recently looking to improve the "stringError" token in VF's lexer to account for more of the many forms of "stringLiteral" when it occurred to me that the recently introduced metastring token (eg, $CR) could potentially replace a portion of the functionality of "stringLiteral" and improve readability at the same time. If anyone agrees, I'll upload a new VF.exe that implements this feature.
The old version of "Hello World" looked like Code: | Require IO #out
#out "Hello, world!"NL"" |
The new version looks like Code: | Require IO #out
#out "Hello, world!" $NL
End |
Any number of metastrings can be abutted, without an explicit concatenation operator, to form a complete string literal. Quoted literals and metastrings can likewise be abutted together, but multiple quoted literals cannot without prepending an underscore to the noninitial literal(s).
You may also notice that the second code above has an END statement whereas the first does not. The most recent release of VF.exe now requires an END statement mainly as a way to suppress the warnings produced by the parser generator I use. If you have an opinion on this, I am all ears. _________________ Brent |
|
Back to top |
|
|
STPendl Full Member
Joined: 20 Aug 2007 Posts: 161 Location: Austria
|
Posted: Aug 12th, 2014, 7:25pm Post subject: Re: Experiment - Better string literals? |
|
|
The new syntax is easier to remember and doesn't look so strange. _________________ Stefan
Any code I post can be freely used, just give credit. |
|
Back to top |
|
|
|
|
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|