Skip to content

Commit

Permalink
Updated documents for removal of Boolean.
Browse files Browse the repository at this point in the history
Clarified semantics for expressions regarding boolean.
  • Loading branch information
shin1m committed Feb 19, 2024
1 parent 5d859fb commit ad473f7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions doc/Literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ This page explains literals.

boolean: 'true' | 'false' ;

xemmai has no boolean type.
The only falsy value is `null`. The other values are all truthy.
`true` is an alias for `1.0`, which is float not integer `1` because bitwise operators have to distinguish integer operations and boolean operations.
`false` is an alias for `null`.

## Integer Literals

integer: digit+ ;
Expand Down
1 change: 0 additions & 1 deletion doc/ObjectTraits.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ It can be called only if the object is in the shared state which means no thread
Method no *1
Throwable yes *3
Null no *1
Boolean no *1
Integer yes *4
Float yes *4
String no *1
Expand Down
3 changes: 0 additions & 3 deletions doc/StackUsage.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@
NUL
|
|N
BOOLEAN
|
|B
INTEGER
|
|I
Expand Down
16 changes: 15 additions & 1 deletion doc/TermExpressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ See [PrimaryExpressions](PrimaryExpressions.md).

unary: ('+' | '-' | '!' | '~')* primary ;

Negate operator (`!`) returns `true` (`1.0`) if the operand is `false` (`null`), returns `false` (`null`) otherwise.

## Multiplicative Expressions

multiplicative: unary (('*' | '/' | '%') unary)* ;
Expand All @@ -26,13 +28,21 @@ See [PrimaryExpressions](PrimaryExpressions.md).

relational: shift (('<' | '>' | '<=' | '>=') shift)* ;

Relational, equality, and identity operators return either `true` (`1.0`) or `false` (`null`).

## Equality Expressions

equality: relational (('==' | '!=') relational)* ;

## Identity Expressions

identity: equality (('===' | '!==') equality)* ;

## And Expressions

and: equality ('&' equality)* ;
and: identity ('&' identity)* ;

Bitwise operators (`&`, `^`, and `|`) do bitwise operations if both the operands are integers, do boolean operations if neither are integers, throws an exception otherwise.

## Xor Expressions

Expand All @@ -46,10 +56,14 @@ See [PrimaryExpressions](PrimaryExpressions.md).

and_also: or ('&&' or)* ;

Evaluates the left operand, returns it if it is `false` (`null`), evaluates the right operand and returns it otherwise.

## Or Else Expressions

or_else: and_also ('||' and_also)* ;

Evaluates the left operand, returns it if it is not `false` (`null`), evaluates the right operand and returns it otherwise.

## Conditional Expressions

conditional: or_else ('?' conditional ':' conditional)? ;
4 changes: 2 additions & 2 deletions doc/WalkThrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ This document walks through xemmai language.
1.5 * 2.0 # => 3.0
"This is a string."
null
true
false
true # => 1.0
false # => null

## Variables

Expand Down

0 comments on commit ad473f7

Please sign in to comment.