Extend your language: Difference between revisions

Added XBS language
(Realize in F#)
(Added XBS language)
Line 3,308:
a <> 1 and b <> 3
a == 1 and b <> 3
</pre>
 
=={{header|XBS}}==
In XBS you are allowed to define custom syntax. The only real purpose for this is quick development or testing.
<lang xbs>#>
newsyntax
@in:CH
@token:does
@CH:"function(Stack){
this.Next(Stack);
this.ChunkWrite(Stack,this.ParseExpression(Stack));
this.TestNext(Stack,\"Bracket\",\"TK_BOPEN\");
this.Move(Stack,2);
this.CodeBlock(Stack);
this.JumpBack(Stack);
if(this.CheckNext(Stack,\"Identifier\",\"otherwise\")){
this.Next(Stack);
this.TestNext(Stack,\"Bracket\",\"TK_BOPEN\");
this.Move(Stack,2);
this.CodeBlock(Stack);
this.JumpBack(Stack);
}
}"
@Interpret:"function(AST,Token){
let Condition = this.Parse(AST,Token[3]);
if(Condition){
this.CondState(AST,Token[4]);
} else {
if(Token[5]){
this.CondState(AST,Token[5]);
}
}
}"
<#
 
func equalsOne(a){
does a == 1 {
log(`Yep! {a} == 1`);
} otherwise {
log(`Nope. {a} != 1`);
}
}
 
equalsOne(1);
equalsOne(2);</lang>
{{out}}
<pre>
Yep! 1 == 1
Nope. 2 != 1
</pre>
 
Anonymous user