Syntax & Semantics
Here we'll see about the Syntax and Semantics of MathX language
In the Introduction Section, we executed the following code:
!: Hello World Program in MathX Language.
main-para:-
println "Hello, World!".
Let us inspect the above code:
Every Statement/Command written in MathX ends with a period
"."
Line starting with
!:
are not executed by the compiler. They are known as comments. These are used to document your code.Lines after the
main-para:-
header are executed.Every Program should end with a newline. Else, the compiler will raise a
SyntaxError
With these inspections, you may now have a conclusion about how a program looks. Let's dive deep into it!
Comments
Comments are used to give documentation to your code. They are useful as they make code readable. Single-Line Comments are only available in MathX. For example:
!: This is not seen by compiler.
main-para:-
println "How are you?".
These can also be used to exclude a part of code to be executed temporarily.
println "Enter a no: ".
println "Dont execute".
println "Enter a no: ".
!: println "Dont execute".
This prevents the compiler from executing the 2nd line. meanwhile, you can debug(i.e., check errors) in your code. Don't forget to remove your comment after debugging.
Last updated