-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #620 from Golmote/prism-basic
Add support for BASIC
- Loading branch information
Showing
12 changed files
with
692 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<h1>BASIC</h1> | ||
<p>To use this language, use the class "language-basic".</p> | ||
|
||
<p>Note: this component focuses on first and second-generation BASICs (such as MSX BASIC, GW-BASIC, SuperBASIC, QuickBASIC, PowerBASIC...).</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>! This is a comment | ||
REM This is a remark</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"This a string." | ||
"This is a string with ""quotes"" in it."</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>42 | ||
3.14159 | ||
-42 | ||
-3.14159 | ||
.5 | ||
10. | ||
2E10 | ||
4.2E-14 | ||
-3E+2</code></pre> | ||
|
||
<h2>Dartmouth Basic example</h2> | ||
<pre><code>5 LET S = 0 | ||
10 MAT INPUT V | ||
20 LET N = NUM | ||
30 IF N = 0 THEN 99 | ||
40 FOR I = 1 TO N | ||
45 LET S = S + V(I) | ||
50 NEXT I | ||
60 PRINT S/N | ||
70 GO TO 5 | ||
99 END</code></pre> | ||
|
||
<h2>GW-BASIC example</h2> | ||
<pre><code>10 INPUT "What is your name: ", U$ | ||
20 PRINT "Hello "; U$ | ||
30 INPUT "How many stars do you want: ", N | ||
40 S$ = "" | ||
50 FOR I = 1 TO N | ||
60 S$ = S$ + "*" | ||
70 NEXT I | ||
80 PRINT S$ | ||
90 INPUT "Do you want more stars? ", A$ | ||
100 IF LEN(A$) = 0 THEN GOTO 90 | ||
110 A$ = LEFT$(A$, 1) | ||
120 IF A$ = "Y" OR A$ = "y" THEN GOTO 30 | ||
130 PRINT "Goodbye "; U$ | ||
140 END</code></pre> | ||
|
||
<h2>QuickBASIC example</h2> | ||
<pre><code>DECLARE SUB PrintSomeStars (StarCount!) | ||
REM QuickBASIC example | ||
INPUT "What is your name: ", UserName$ | ||
PRINT "Hello "; UserName$ | ||
DO | ||
INPUT "How many stars do you want: ", NumStars | ||
CALL PrintSomeStars(NumStars) | ||
DO | ||
INPUT "Do you want more stars? ", Answer$ | ||
LOOP UNTIL Answer$ <> "" | ||
Answer$ = LEFT$(Answer$, 1) | ||
LOOP WHILE UCASE$(Answer$) = "Y" | ||
PRINT "Goodbye "; UserName$ | ||
|
||
SUB PrintSomeStars (StarCount) | ||
REM This procedure uses a local variable called Stars$ | ||
Stars$ = STRING$(StarCount, "*") | ||
PRINT Stars$ | ||
END SUB</code></pre> | ||
|
||
<h2>Known failures</h2> | ||
<p>There are certain edge cases where Prism will fail. | ||
There are always such cases in every regex-based syntax highlighter. | ||
However, Prism dares to be open and honest about them. | ||
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug. | ||
</p> | ||
|
||
<h3>Two double quotes inside a comment</h3> | ||
<pre><code>! This "comment" is broken | ||
REM This "remark" is broken</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
! Foobar | ||
REM Foobar | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", ["! Foobar"]], | ||
["comment", [["keyword", "REM"], " Foobar"]] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
Oops, something went wrong.