Skip to content

Commit

Permalink
Formatting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JaDogg committed Dec 28, 2023
1 parent f8e328f commit a380504
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/Note.astro
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const { mode } = Astro.props;
<img
alt="Yaksha Programming Language Mascot"
src="/imgs/yaka-mascot.png"
class="${iconStshrink-0 h-24 w-24"
class="my-auto mx-2 shrink-0 h-24 w-24"
/>
)
}
<slot />
<slot />
</div>
47 changes: 43 additions & 4 deletions src/pages/docs/0001-features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ def get_arg(n: int) -> str:
def get_global_arg(n: int) -> str:
ccode "yk__sdsdup(global_args[yy__n])"
```
<Note mode="icon">If `ccode` is there instead of an argument, then it is used as the message body.</Note>
<Note mode="mascot">
* If `ccode` is there instead of an argument, then it is used as the message body.
</Note>

<details>
<summary>Click to see output C code</summary>
Expand Down Expand Up @@ -572,7 +574,40 @@ def main() -> int:
*`hmget(Array[MEntry[K,T]], K) -> T` - Get item from an `Array[MEntry[K,T]]`
*`hmgeti(Array[MEntry[K,T]], K) -> int` - Get item index from an `Array[MEntry[K,T]]` (-1 if not found)
*`cast("T", X) -> T` - Data type casting builtin
*`qsort(Array[T],Function[In[Const[AnyPtrToConst],Const[AnyPtrToConst]],Out[int]]) -> bool` - Sort an array, returns True if successful
*`qsort(Array[T], COMP) -> bool` - Sort an array, returns True if successful

```yaksha
# Comparision is a function of type:
# Function[In[Const[AnyPtrToConst],Const[AnyPtrToConst]],Out[int]])
#
# Example:
def cmp_int(a: Const[AnyPtrToConst], b: Const[AnyPtrToConst]) -> int:
# Compare two given integers
val_a: int = unref(cast("Ptr[int]", a))
val_b: int = unref(cast("Ptr[int]", b))
return val_b - val_a
def print_array(x: Array[int]) -> None:
print("len=")
println(len(x))
pos = 0
length: int = len(x)
while pos < length:
print(x[pos])
print(" ")
pos = pos + 1
println("")
def main() -> int:
x1 = array("int", 1, 2, 3, 3, 2, 1, 5, 4)
println("before x1:")
print_array(x1)
qsort(x1, cmp_int)
println("after x1:")
print_array(x1)
```

*`iif(bool, T, T) -> T` - Ternary functionality
*`foreach(Array[T],Function[In[T,V],Out[bool]],V) -> bool` - For each element in array execute given function
*`countif(Array[T],Function[In[T,V],Out[bool]],V) -> int` - For each element in array count if function returns true
Expand All @@ -582,7 +617,9 @@ def main() -> int:
*`make("T") -> Ptr[T]` - Allocate a single object.
*`inlinec("T", "code") -> T` - Inline `C` code resulting in `T` data type. Example - `inlinec("int", "sizeof(char)")`

<Note mode="icon">Builtin functions may call different implementations based on input.</Note>
<Note mode="mascot">
* Builtin functions may call different implementations based on input.
</Note>



Expand All @@ -607,7 +644,9 @@ def main() -> int:
return 0
```

<Note mode="icon">Must ensure array elements are freed. `int` need not be deleted as they are primitive types.</Note>
<Note mode="mascot">
* Must ensure array elements are freed. `int` need not be deleted as they are primitive types.
</Note>



Expand Down
8 changes: 6 additions & 2 deletions src/pages/docs/0005-grammar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ primary: "True" | "False" | "None" | number | string | triple_quote_string | nam
"(" expr ")"
```

<Note mode="icon">Based on [lox grammar](https://craftinginterpreters.com/appendix-i.html) and [Python operator precedence](https://www.mathcs.emory.edu/~valerie/courses/fall10/155/resources/op_precedence.html).</Note>
<Note mode="mascot">
* Based on [lox grammar](https://craftinginterpreters.com/appendix-i.html) and [Python operator precedence](https://www.mathcs.emory.edu/~valerie/courses/fall10/155/resources/op_precedence.html).
</Note>



Expand All @@ -138,5 +140,7 @@ eof: "end of file"
ba_indent: "increase in indentation"
ba_dedent: "decrease is indentation"
```
<Note mode="icon">`ba_indent` and `ba_dedent` gets calculated before parsing in `block_analyzer` phase.</Note>
<Note mode="mascot">
* `ba_indent` and `ba_dedent` gets calculated before parsing in `block_analyzer` phase.
</Note>

0 comments on commit a380504

Please sign in to comment.