Plugins
The biggest feature of fluentscript is the concept of plugins. Almost every feature of fluentscript is a plugin. A fluentscript plugin extends the syntax and features at the various levels of the core fluentscript language. Plugins are relatively easy to write and there are several ( almost 40 ) examples of them in the codebase. All the core keywords/features of fluentscript ( var, if, while, for, function, etc ) are implemented as system level plugins. These system level plugins basically make fluentscript resemble javascript to a good degree. Aside from the system level plugins, there are additional plugins to extend datatypes, create custom expressions and statements among other additional features.
1. Aggregate
Description: Provides sum, min, max, avg, count aggregate functions for lists.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.AggregatePlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\AggregatePlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289916
// Aggregate plugin allows sum, min, max, avg, count aggregate functions to
// be applied to lists of objects.
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var result = 0;
// Example 1: Using format sum of <expression>
result = sum of numbers;
result = avg of numbers;
result = min of numbers;
result = max of numbers;
result = count of numbers;
// Example 2: Using format sum(<expression>)
result = sum( numbers );
result = avg( numbers );
result = min( numbers );
result = max( numbers );
result = count( numbers );
Back to top
2. Alias
Description: Provides using an alias for a keyword such as set for var inside a script.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.AliasPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\AliasPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1349987
// Alias plugin allows setting up alias of words to other words/tokens in a script
alias def to function
alias set to var
// After the alias configured
set result1 = 1
var result2 = 2
Back to top
3. AndOr
Description: Provides words "and" "or" to be used in place of && and ||
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.AndOrPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\AndOrPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1343614
// AndOr plugin allows the words "and" "or" to be used in place of && ||
if ( i > 30 and j < 20 ) then print works
if ( i < 30 or j > 20 ) then print works
Back to top
4. Bool
Description: Provides synonyms yes/no, on/off for bool values true/false.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.BoolPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\BoolPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1290454
// Bool plugin allows aliases for true/false
var result = on;
var result = off;
var result = yes;
var result = no;
Back to top
5. Compare
Description: Provides synonyms for comparison operators
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.ComparePlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\ComparePlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1290453
// Compare plugin allows word aliases for the comparison operators. See list below
//
// ALIAS: FOR:
// "less than", "<"
// "before", "<"
// "below", "<"
// "is below", "<"
// "is before", "<"
// "more than", ">"
// "after", ">"
// "above", ">"
// "is after", ">"
// "is above", ">"
// "less than equal", "<="
// "less than equal to", "<="
// "more than equal", ">="
// "more than equal to", ">="
// "is", "=="
// "is equal", "=="
// "is equal to", "=="
// "equals", "=="
// "equal to", "=="
// "not", "!="
// "not equal", "!="
// "not equal to", "!="
// "is not", "!="
// "is not equal to", "!="
// Example 1: Using <
if a less than b then
if a before b then
if a below b then
if a is before b then
if a is below b then
// Example 2: Using <=
if less than equal then
if less than equal to then
// Example 2: Using >
if a more than b then
if a after b then
if a above b then
if a is after b then
if a is above b then
Back to top
6. ConstCaps
Description: Allows defining constants with UPPERCASE letters.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.ConstCapsPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\ConstCapsPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1345095
// Const caps plugin allows the creation of constants using capital letters
// Constants are defined if all the letters are uppercase
// Example 1
MIN_SIZE = 10
MAX_SIZE = 20
// Example 2 : Multiple declarations with different constants.
FIXED = true, DUE_DATE = "2012-5-10"
// Example 3 : Using constants with other plugins ( Date, DateNumber )
STARTS = 3/10/2012
ENDS = June 10th 2012
// KNOWN ISSUE: Constants should be limited to numbers, bool, strings,
// but right now there is a bug where a constant can be assigned a date.
Back to top
7. Date
Description: Provides word based representation for dates e.g December 21st 2011
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.DatePlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\DatePlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289913
// Date plugin allows date expressions in a friendly format like January 1 2001;
// Following formats are supported.
var date = January 1st 2012;
var date = Jan
date = jan 10
date = Jan 10 2012
date = Jan 10, 2012
date = Jan 10th
date = Jan 10th 2012
date = Jan 10th, 2012
date = January 10
date = January 10, 2012
date = January 10th
date = January 10th, 2012
date = January 10th 2012 at 9:20 am;
if today is before December 25th 2011 then
print Still have time to buy gifts
Back to top
8. DateNumber
Description: Provides representation of dates in the form of numbers e.g. 1/27/2012
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.DateNumberPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\DateNumberPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289913
// Date number plugin allow you to specify dates in the form of numbers as
// samples below.
// The separator between months/days/years can be "/", "-", "\"
var date1 = 1/27/1978;
var date2 = 4-20-1979 at 4:30pm;
var date3 = 6\10\2012 at 7:45am;
Back to top
9. Day
Description: Provides alias and word based representation for days e.g Tuesday, Saturday, today, tommorrow
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.DayPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\DayPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289914
// Day plugin allows days of the week to be used as words.
// lowercase and uppercase days are supported:
// 1. Monday - Sunday
// 2. monday - sunday
// 3. today, tomorrow, yesterday
var day = Monday;
var date = tomorrow at 3:30 pm;
if tommorrow is Saturday then
print Thank god it's Friday
Back to top
10. Def
Description: Allows the word "def" to be used instead of "function" when declaring functions.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.DefPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\DefPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1333227
// Def plugin allows the word "def" to be used instead of "function" when declaring functions.
def add( a, b )
{
return a + b
}
Back to top
11. Email
Description: Provides using emails without quotes such as john.doe@company.com
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.EmailPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\EmailPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1332189
// Email plugin enables recognition of emails as strings without using quotes,
// such as john.doe@company.com
email1 = john.doe@company.com
email2 = batman2012@gotham.com
email3 = super.man_1@metropolis.com
Back to top
12. Env
Description: Provides access to environment variables
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.EnvPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\EnvPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289918
// Env plugin allows direct access to environment variables via the "env" object.
// Example 1: Access to user variables only via the ".user" property of env.
result = env.user.path;
// Example 2: Access to system variables via the ".sys" property of env.
result = env.sys.path;
// Example 3: Access to environment variable without specifying sys or user.
result = env.path;
result = env.SystemRoot;
Back to top
13. Fail
Description: Terminates a program abruptly with a message.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.FailPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\FailPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1387648
// Terminates a program abruptly with a message.
fail 'settings file not found, exiting application'
fail "file : #{path} not found, exiting application"
fail 0
Back to top
14. FileExt
Description: Allows represnting file extension with out having to surround them in quotes e.g. .xml, .doc, *.dll
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.FileExtPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\FileExtPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1387575
// Allows represnting file extension with out having to surround them in quotes
// e.g. such as .doc, or *.doc
// Format: "*" "." <extension_name>
// NOTE: The "*" is optional.
some_file_operation( 'c:\\app\\src\\', .pdb )
some_file_operation( 'c:\\app\\src\\', *.dll )
some_file_operation( 'c:\\app\\src\\', .svn )
some_file_operation( 'c:\\app\\src\\', .exe )
Back to top
15. FileIO
Description: Provides basic File/Directory operations.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.FileIOPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\IOPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1387646
// Provides basic File/Directory operations.
// Case 1: Fluent-mode ( files ) - with Uri plugin and FluentMember plugin
create file c:\temp\fs.txt contents: 'testing'
append file c:\temp\fs.txt contents: 'testing'
copy file c:\temp\fs.txt to: c:\temp\fs.log
move file c:\temp\fs.txt to: c:\temp\fs2.txt
rename file c:\temp\fs.txt to: 'fs1.txt'
delete file c:\temp\fs.txt
var exists = file exists c:\temp\fs.txt
// Case 2: Fluent-mode ( directories ) - with Uri plugin and FluentMember plugin
create dir c:\temp\fs
copy dir c:\temp\fs, to: c:\temp\fs1
move dir c:\temp\fs2, to: c:\temp\fs
rename dir c:\temp\fs1, to: 'fs2'
delete dir c:\temp\fs
var exists = dir exists c:\temp\fs
// Case 3: Files ( Explicit calls )
File.Create( 'c:\\build\\log.txt', 'contents' )
File.Append( 'c:\\build\\log.txt', 'contents' )
File.Copy ( 'c:\\build\\log.txt', 'c:\\build\\file2.txt')
File.Rename( 'c:\\temp\\fs.txt', 'fs-io-test2.txt', true );
File.Delete( 'c:\\temp\\fs.txt' )
File.Move ( 'c:\\temp\\fs.txt', 'c:\\temp\\fs-io-test.txt' )
// Case 4: Directories ( Explicit calls )
// NOTE: This is similar to case 3 where each call is "Dir.<method>( <paramlist> )"
Back to top
16. Fluent Functions
Description: Provides ability to call functions with spaces in name. e.g. refill inventory
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.Fluent FunctionsPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\FluentFuncPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1334088
// Fluent Func plugins allows calling functions with spaces.
// @summary: finds doctors based on the zip code provided and
// the specicality and accepted insurance
// @arg: name: zip, type: number, desc: The zipcode, examples: 11201
// @arg: name: specialty, type: text, desc: Specialization, examples: 'Familye'
// @arg: name: insurance, type: text, desc: Name of insurance, examples: 'empire'
function find_doctors_by_zipcode ( zip, specialty, insurance )
{
// ... some code here.
}
// @arg: name: product, desc: The product id, type: text, examples: 'AS-1232'
// @arg: name: amount, desc: Number of items, type: text, examples: 23
function refill_inventory( product, amount )
{
// ... some code here.
}
// Call functions replacing "_" with space - parameters are optional if function call
// is on a single line.
// Example 1:
find doctors by zipcode 11200, 'family practice', 'empire insurance'
// Example 2:
refill inventory 'KL-131', 200
Back to top
17. Fluent Members
Description: Provides ability to access properties and methods on a custom c# object without the
"."( dot operator ).
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.Fluent MembersPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\FluentFuncPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1338334
// Fluent Member plugin allows properties and methods to be accessed without "."
// Supported ways of calling methods:
// 1. class property
// 2. class method
// 3. instance property
// 4. instance method
// 5. prop class
// 6. prop instance
// 7. method class
// 8. method instance
// NOTE: In the above list "class" designates access to class level/static members
// FLUENT CALLS
// Example 1 : method instance
activate user 'kreddy'
// Example 2 : method class arg
delete file c:\temp.txt
// Example 3 : class method arg
file exists c:\temp.txt
Back to top
18. Function Wildcard
Description: Provides a 'wildcard' like ability to functions so that 2 functions that have different names are
associated with the same function.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.Function WildcardPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\FuncWildCardPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1346790
// FuncWildCard plugin allows using functions with changing names allowing
// a single function to handle function calls with different names.
// @summary: A single function can be called using wildcards
// @arg name: wildcard, type: string, example: "by name password email role"
// @arg name: wildcardParts, type: list, example: ['by', 'name' 'password', 'email', 'role' ]
// @arg name: args, type: list, example: [ 'kreddy', 'admin' ]
function "create user by" * ( wildcard, wildcardParts, args )
{
person = new Person()
// Option 1: Use the full name to determine what to do
if wildcard== "name password email role"
{
person.Name = args[0]
person.Password = args[1]
person.Email = args[2]
person.Role = args[3]
}
// Option 2: Use the individual name parts
for( var ndx = 0; ndx < wildcardParts.length; ndx++)
{
part = wildcardParts[ndx]
if part == "name" then person.Name = args[ndx]
else if part == "password" then person.Password = args[ndx]
else if part == "email" then person.Email = args[ndx]
else if part == "role" then person.Role = args[ndx]
}
person.Save()
}
create user by name email ( "user02", "user02@abc.com" )
create user by name password email role ( "user01", "password", "user01@abc.com", "user" )
Back to top
19. HashComment
Description: Provides single line comment using # instead of //
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.HashCommentPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\HashCommentPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1344512
// Allows using # for single line comments instead of //
# Single line comment
// Also single line comment
Back to top
20. Holiday
Description: Provides holiday names e.g. Christmas, Independence Day, Christmas Eve, New Years
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.HolidayPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\HolidayPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289952
// Holiday plugin allows references to dates using Holiday names such as:
// Christmas
// Independence day
// Valentines day
// New Years
if today is New Years 2012 then
print happy new year!
Back to top
21. Linq
Description: Provides partial support for linq-like queries on lists.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.LinqPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\LinqPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1290456
// Linq plugin is a Light-weight and partial version of Linq style queries and comprehensions
// NOTE: This has limited functionality as of this release.
var books = [
{ name: 'book 1', pages: 200, author: 'homey' },
{ name: 'book 2', pages: 120, author: 'kdog' },
{ name: 'book 3', pages: 140, author: 'homeslice' }
];
// Case 1: start with source <books> and system auto creates variable <book>
var favorites = books where book.pages < 150 and book.author == 'kdog';
// Case 2: using from <variable> in <source>
var favorities = from book in books where book.pages < 150 and book.author == 'kdog';
Back to top
22. Log
Description: Provides logging ability to either the console or a log file
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.LogPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\LogPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1349989
// CONFIGURATION
// 1. Set level to "error" and log to console
log.configure( 'error', 'console' )
// 2. Fluen mode, set level = "error" and log to console.
log configure 'error', 'console'
// 3. File logging: set level to "warn" and log to file
log configure 'warn', 'c:/temp/myapp.log'
// 4. File logging: set level to "warn" and log to file with a name format.
// log file name will be converted to "myapp-2012-07-15-time-09-45-12.log"
log configure 'warn', 'c:/temp/myapp.log', '${yyyy-MM-dd}-time-${HH-mm-ss}'
// 5. Get the current log level : this is only a getter property
print( log.level )
// LOGGING
// 1. Using OO ( object oriented ) syntax e.g. "log.<method>"
log.error( 'an error occurred' )
// 2. Using OO syntax with formatting
log.warn( 'could not load {0}', 'blogs' )
// 3. Using OO syntax in fluent mode
log info 'finished updating data'
// 4. functional mode - without prefixing with "log."
error 'unable to initialize'
warn 'could not send notification'
info 'finished updating data'
// NOTES: Log-level
// 1. fatal
// 2. error
// 3. warn
// 4. info
// 5. debug
// 6. put ( this will always output the log message )
Back to top
23. MachineInfo
Description: Provides markers/comments that are checked for syntax
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.MachineInfoPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\MachineInfoPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1349266
// Machine info plugin provides variable names to get information about the machine
print ( @machine )
print ( @domain )
print ( @user )
print ( @cmdline )
print ( mac.numprocs )
print ( mac.osname )
print ( mac.osversion )
print ( mac.osspack )
print ( mac sysdir )
print ( mac memory )
print ( mac version )
print ( mac currentdir )
// NOTES:
// Any of the properties above can be prefixed with either
// 1. mac.<property>
// 2. mac <property>
// 3. @<property>
Back to top
24. Marker
Description: Provides markers/comments that are checked for syntax
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.MarkerPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\MarkerPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1293552
// Marker plugin allows you to mark code like comments but in the form of statements
// so that syntax is checked. This allows for structured comments.
// Case1 : Todo
@todo: i need to add extra comments here
// Case2 : Todo quoted
@todo: "I need to add extra checks here and
also do additional cleanup of code"
// Case 3 : bug
@bug: 'this bug related to parsing'
@bug: this bug related to johns code!
Back to top
25. Money
Description: Provides dollar sign $ support for numbers.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.MoneyPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\MoneyPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289917
// Money plugin simply allows the $ to be prefixed to numbers.
var salary = $225.50;
if salary is more than $160 then
print I worked overtime.
Back to top
26. NamedIndex
Description: Allows using ruby-style string literals such as :user01 where :user01 equals 'user01'
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.NamedIndexPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\NamedIndexPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1650365
// Named index plugin allows numeric access to array items using non-0 based index
// and in a fluent approach.
var items = [1, 2, 3, 4, 5]
var result = 2nd item
// Note in the example above 3 things:
// 1. "2nd" represents the index to access. this is equivalent to items[1]
// 2. if variable is "items"( plural ), you can type "item"( singular )
// 3. This is always 1 based. e.g. 3rd item == items[2]
Back to top
27. Percent
Description: Provides using a percent sign % after a number to indicate percentage
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.PercentPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\PercentPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1357973
// Percent plugin allow using a percent sign % after a number to indicate percentage
a = 25%
b = 75 %
// NOTES
// 1. You can not use this when an identifier comes after the "%"
// 2. You can not use this when another number comes after the "%"
Back to top
28. Print
Description: Provides functionality to print to console a line of text without wrapping around quotes.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.PrintPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\PrintPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1290455
// Print plugin derives from the "TakeoverPlugin"
// Takeovers are keywords that consume the entire line of text in the script
// after the keyword.
// In this case of the Print plugin, it consume the rest of the line and you
// don't need to wrap text around quotes.
var language = 'fluentscript';
print No need for quotes in #{language} if text to print is on one line
Back to top
29. Records
Description: Supports representing data in a table/csv like format.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.RecordsPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\RecordsPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1296274
// Supports representing data in a table/csv like format
// 1. The top most row must the the header names without spaces
// 2. The header names must be separated by "|"
// 3. The columns in the data rows must be separated by either "|" or ","
set books1 = [
name | pages | artist
'batman' | 110 | 'john'
'xmen' | 120 | 'lee'
'daredevil' | 140 | 'maleev'
];
set books2 = [
name | pages | artist
'batman' , 110 , 'john'
'xmen' , 120 , 'lee'
'daredevil' , 140 , 'maleev'
];
Back to top
30. Repeat
Description: Repeat plugin provides convenient ways to execute loops.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.RepeatPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\RepeatPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1383748
// Repeat plugin provides convenient ways to execute loops.
// Case 1: for(it = 1; it <= 10; it++ )
repeat to 10
print "hi"
// Case 2: for(it = 2; it <= 10; it++ )
repeat 2 to 10
print "hi"
// Case 3: for(it = 2; it < 10; it++ )
repeat 2 to < 10
print "hi"
// Case 4: for(it = 2; it < 10; it+= 2 )
repeat 2 to < 10 by 2
print "hi"
// Case 5: for( ndx = 0; ndx <= 10; ndx++ )
repeat ndx to 10
print "hi"
// Case 6: for( ndx = 0; ndx < 10; ndx++ )
repeat ndx to < 10
print "hi"
// Case 7: for( ndx = 1; ndx <= 10; ndx++ )
repeat ndx = 1 to 10
print "hi"
// Case 8: for( ndx = 1; ndx < 10; ndx++ )
repeat ndx = 1 to < 10
print "hi"
// Case 9: for( ndx = 1; ndx < 10; ndx+= 2)
repeat ndx = 1 to < 10 by 2
print "hi"
Back to top
31. Round
Description: Provides rounding of numbers using round, round up, round down.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.RoundPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\RoundPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1292482
// Round plugin provides functions to round, round up or round down numbers.
var a = 2.3;
// Rounds the number using standing round technique of .4
var b = round 2.3;
// Gets rounded up to 3
var c = round up 2.3;
// Gets rounded down to 2
var d = round down 2.3;
Back to top
32. Run
Description: Provides alternative ways of calling a function.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.RunPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\RunPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289922
// Run plugin provides alternate way to call a function for fluid syntax.
// Notes:
// 1. The keyword "function" can be aliased with the word "step"
// 2. The name of a function can be in quotes with spaces.
// This is a function with 0 parameters so parentheses are not required
step Cleanup
{
// do something here.
}
// This is a function with string for name and 0 parameters so parentheses are not required
step 'Clean up'
{
// do something here.
}
// Example 1: Call function normally
Cleanup();
// Example 2: Call function using Run keyword
run Cleanup();
// Example 3: Call function using run without parenthesis for function name.
run Cleanup;
// Example 4: Call function with spaces in name using run with quotes for function name.
run 'Clean up';
// Example 5: Call function with spaces using run and keyword.
run step 'Clean up';
Back to top
33. Set
Description: Allows the word "set" to be used instead of "var" when declaring variables
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.SetPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\SetPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1333226
// Set plugin allows using the word 'set' instead of 'var' when declaring variables
set age = 33
Back to top
34. Sort
Description: Provides ability to sort of list of either basic types of objects with properties.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.SortPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\SortPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1293513
// Sort plugin allows you to sort a list
// Case 1: sort list of basic types
var numbers = [4, 3, 1, 7, 5, 2, 6];
sort numbers asc
sort numbers desc
// Case 2: start with source <books> and system auto creates variable <book>
var books = [
{ name: 'book 1', pages: 200, author: 'homey' },
{ name: 'book 2', pages: 120, author: 'kdog' },
{ name: 'book 3', pages: 140, author: 'homeslice' }
];
sort books by book.pages asc
sort books by book.pages desc
sort i in books by i.pages desc
Back to top
35. Step
Description: Allows the word "step" to be used instead of "function" when declaring functions.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.StepPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\StepPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1343616
// Step plugin allows the word "step" to be used instead of "function" when declaring functions.
step add( a, b )
{
return a + b
}
Back to top
36. StringLiteral
Description: Allows using ruby-style string literals such as :user01 where :user01 equals 'user01'
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.StringLiteralPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\StringLiteralPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1650237
// Allows using ruby-style string literals such as :user01 where :user01 equals 'user01'
name = :user01
lang = :fluentscript
if( :batman == 'batman' ) print( "works" );
Back to top
37. Suffix
Description: Provides enables the use of functions as postfix operators on constants
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.SuffixPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\SuffixPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1331001
// Suffix plugin enables the use of functions as postfix operators on constants.
// create hours with timespan object using number of hours supplied
function hours( num )
{
return new TimeSpan( 0, num, 0 , 0 )
}
// create minutes with timespan object using number of minutes supplied
function minutes( num )
{
return new TimeSpan(0, 0, num, 0 )
}
// timespan objects can be added together
var time = 3 hours + 20 minutes;
Back to top
38. Swap
Description: Provides ability to swap values of 2 variables in 1 statement e.g swap a with b;
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.SwapPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\SwapPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289912
// Swap plugin provides 1 line statement to swap variables.
var a = 1, b = 2;
// Swap values in 1 statement.
// Instead of needing a third variable.
swap a with b;
Back to top
39. Time
Description: Provides time representation in format 12:30 pm
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.TimePlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\TimePlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289920
// Time plugin provides a convenient way to represent time in fluent syntax.
var t = 12:30 pm;
if t is 12:30 pm then
print it's time to go to lunch!
// Time plugin provides a convenient way to represent time in fluent syntax.
var t = 12:30 pm;
if t is 12:30 pm then
print it's time to go to lunch!
Back to top
40. TypeOf
Description: Provides checking of data types
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.TypeOfPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\TypeOfPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1289920
// Type of plugins gets the type of an expression.
function inc(a) { return a + 1; }
dataType = typeof 'fluentscript' // 'string'
dataType = typeof 12 // 'number'
dataType = typeof 12.34 // 'number'
dataType = typeof true // 'boolean'
dataType = typeof false // 'boolean'
dataType = typeof new Date() // 'datetime'
dataType = typeof 3pm // 'time'
dataType = typeof [0, 1, 2] // 'object:list'
dataType = typeof { name: 'john' } // 'object:map'
dataType = typeof new User('john') // 'object:ComLib.Lang.Tests.Common.User'
dataType = typeof inc // 'function:inc'
Back to top
41. Units
Description: Provides usage of units of measure such as length, weight
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.UnitsPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\UnitsPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1331000
// Units plugin allows the usage of units of measure such as length, weight
enable units;
// inches, bytes are base types. everything is relative to the base types
// In examples below, the units will get converted to the measurement on the
// left hand side. e.g. 3 feet + 5 inches will get converted to datatype
// LUnit with value in feet and basevalue in inches.
var result1 = 3 feet + 5 inches + 10 yards + 2 miles
var result2 = 1 meg + 30 kb + 50 B + 2 gigs
// Each unit of measure is based on a basevalue with a relative value.
// e.g.
// type basevalue relative values
// length inches feet, yard, mile
// weight ounces milligrams, grams, kilograms
// computerspace bytes kilobytes, megabytes, gigabytes
print feet: #{result1.Value} , inches: #{result1.BaseValue}
print megs: #{result2.Value} , bytes: #{result2.BaseValue}
Back to top
42. Uri
Description: Provides url and folder representations as strings without quotes.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.UriPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\UriPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1293481
// Uri plugin allows you urls and file paths without surrounding them in
// quotes as long as there are no spaces. These are interpreted as strings.
var url1 = www.yahoo.com;
var url2 = http://www.google.com;
var url3 = http://www.yahoo.com?user=kishore%20&id=123;
var file1 = c:\users\kishore\settings.ini;
var file2 = c:/data/blogposts.xml;
// Since this file has a space in it... you have to surround in quotes.
var file3 = 'c:/data/blog posts.xml';
Back to top
43. VariablePath
Description: Provides representation of file paths in more convenient ways.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.VariablePathPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\VariablePathPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1358170
// Provides representation of file paths in more convenient ways
// Set the home dir
home = c:\myapp\
script = "build"
// Case 1: Typical approach
file = home + "\\build\\build.xml"
// Case 2: VariablePath plugin simple case
// The @ is optional on the first variable in the path.
file = home\build\script.xml
file = @home\build\script.xml
// Case 3: Use variables in the path by prefixing @
file = @home\build\@script.xml
file = @home\build\@script-build.xml
file = @home\build\@script.build.xml
// Case 4: Use variables by prefixing with @ and surrounding by {}
// This is only needed when separating a variable name from another variable name.
file = @home\build\@{script}build.xml
file = @home\build\@{script}-build.xml
file = @home\build\@{script}.build.xml
// NOTE:
// This plugin is useful since the beginning drive letter ( "c:\" or "d:\" )
// should NOT be hardcoded. This plugin removes the need to:
// 1. use "+" for appending parts of the path
// 2. use doublequotes for wrapping the path name e.g. "\build\appbuild.fs"
Back to top
44. Version
Description: Version plugin enables representation of versions using format 1.2.3.4.
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.VersionPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\VersionPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1387576
// Version plugin enables representation of versions using format 1.2.3.4.
// This is particularily useful for when fluentscript is used for build automation.
// e.g. 0.9.8.7
version = 0.9.8.7
version2 = 0.9.8
print( version.Major )
print( version.Minor )
print( version.Revision )
print( version.Build )
Back to top
45. Words
Description: Provides ability to use multi-word strings. e.g fluent script = 'fluent script'
Date: 12/1/2012
Version: 0.9.8.9
Type: FluentScript.dll - ComLib.Lang.Extensions.WordsPlugin
Core source: src\Lib\CommonLibrary.NET\_Core\Lang\Plugins\Parser\WordsPlugin.cs
Example full: http://fluentscript.codeplex.com/SourceControl/changeset/view/83734#1311195
// Words plugin enables the registration of custom text/words into the language
// which are then immediately available for use.
// They are basically an alternative to not having to surround text in double quotes
// Only
@words( nasdaq, fluent script )
if ( "fluent script" == fluent script ) then
print( "works" )
Back to top