try out syntax highlighting

This commit is contained in:
Renaud Pawlak 2015-11-26 19:40:22 +01:00
parent 8eeb8303c5
commit 50fdf81cc4
2 changed files with 33 additions and 27 deletions

View File

@ -21,6 +21,7 @@ JSweet allows the use of Java primitive types (and associated literals).
Examples of valid statements:
``` java
// warning '==' behaves like the JavaScript one at runtime
int i = 2;
assert i == 2;
@ -30,6 +31,7 @@ Examples of valid statements:
assert s == "string02"; // JavaScript '=='
boolean b = false;
assert !b;
```
#### Allowed Java objects
@ -125,6 +127,7 @@ Here follows the list of allowed Java classes in JSweet:
Examples of valid statements:
``` java
// warning '==' behaves like the JavaScript one at runtime
Integer i = 2;
assert i == 2; // JavaScript '=='
@ -133,11 +136,13 @@ Examples of valid statements:
assert d == "6"; // JavaScript '=='
BiFunction<String, Integer, String> f = (s, i) -> { return s.substring(i); };
assert "bc" == f.apply("abc", 1); // JavaScript '=='
```
#### Java arrays
Arrays can be used in JSweet and are transpiled to JavaScript arrays. Array initialization, accesses and and iteration are all valid statements.
``` java
int[] arrayOfInts = { 1, 2, 3, 4};
assert arrayOfInts.length == 4;
assert arrayOfInts[0] == 1;
@ -145,6 +150,7 @@ Arrays can be used in JSweet and are transpiled to JavaScript arrays. Array init
arrayOfInts[i] = arrayOfInts[i] - 1;
assert arrayOfInts[i] == i;
}
```
#### Core JavaScript API

View File

@ -96,7 +96,7 @@ JSweet allows the use of Java primitive types (and associated literals).
\noindent
Examples of valid statements:
\begin{lstlisting}
\begin{lstlisting}[language=Java]
// warning '==' behaves like the JavaScript one at runtime
int i = 2;
assert i == 2;
@ -194,7 +194,7 @@ Here follows the list of allowed Java classes in JSweet:
\noindent
Examples of valid statements:
\begin{lstlisting}
\begin{lstlisting}[language=Java]
// warning '==' behaves like the JavaScript one at runtime
Integer i = 2;
assert i == 2; // JavaScript '=='
@ -209,7 +209,7 @@ assert "bc" == f.apply("abc", 1); // JavaScript '=='
Arrays can be used in JSweet and are transpiled to JavaScript arrays. Array initialization, accesses and and iteration are all valid statements.
\begin{lstlisting}
\begin{lstlisting}[language=Java]
int[] arrayOfInts = { 1, 2, 3, 4};
assert arrayOfInts.length == 4;
assert arrayOfInts[0] == 1;