Syntax highlighting using Mediawiki formatting: Difference between revisions

m
→‎{{header|Wren}}: Minor change
(Added PL/M)
m (→‎{{header|Wren}}: Minor change)
(2 intermediate revisions by 2 users not shown)
Line 698:
{{works with|8080 PL/M Compiler}} ... under CP/M (or an emulator)
Note that PL/M doesn't have in-built I/O or standard libraries, hence the need to define the various BDOS system calls.<br>
|As CP/M doesn't have redirection, the source file and output file names must be specified on the command line, e.g. if the source is in D:SYNTAX.PLM and the desired output file is D:SYNTAX.OUT and the program is compiled to D:SYNTAX.COM, then the command:<br>
<code>D:SYNTAX D:SYNTAX.PLM D:SYNTAX.OUT</code><br> will create SYNTAX.OUT as a copy of SYNTAX.PLM with the markup for the highlighting. Note the output file must not exist before running the program.<br>
The output is also echoed to the console.
100H: ''/* SYNTAX HIGHLIGHT A PL/M SOURCE USING MEDIAWIKI MARKUP */''
Line 1,045:
'''EOF'''
 
=={{header|Python}}==
Line 1,254 ⟶ 1,253:
''/* this code should now be saved to''
'' /* a file named */''
'' syntax_highlightingSyntax_highlighting_using_Mediawiki_formatting.wren */''
 
=={{header|XPL0}}==
Key words in XPL0 are easy to distinguish from variable names because
they start with lowercase letters while variables start with uppercase
letters. This program highlights its own code properly, but it will not
properly highlight all possible cases, such as when key words appear
in quoted strings.
'''proc''' CharOut(Ch);
'''int''' Ch;
'''begin'''
'''case''' Ch '''of'''
^&apos;: Text(0, "&amp;apos;");
^&amp;: Text(0, "&amp;amp;");
^&lt;: Text(0, "&amp;lt;");
^&gt;: Text(0, "&amp;gt;")
'''other''' ChOut(1, Ch);
'''end''';
'''int''' Ch;
'''loop''' '''begin'''
ChOut(1, $20); ''\leading space''
Ch:= ChIn(1);
'''loop''' '''begin'''
'''while''' Ch &lt;= $20 '''do''' ''\pass whitespace to output''
'''begin'''
'''if''' Ch = $1A ''\EOF\'' '''then''' '''return''';
ChOut(1, Ch);
'''if''' Ch = $0A ''\LF\'' '''then''' '''quit''';
Ch:= ChIn(1);
'''end''';
'''if''' Ch = ^\ '''then''' ''\pass comment to output''
'''begin'''
Text(0, "&apos;&apos;"); ''\in italics''
ChOut(1, Ch);
Ch:= ChIn(1);
'''while''' Ch#^\ &amp; Ch#$0A ''\LF\'' '''do'''
'''begin'''
CharOut(Ch); Ch:= ChIn(1);
'''end''';
'''if''' Ch = ^\ '''then''' ChOut(1, Ch);
Text(0, "&apos;&apos;");
'''if''' Ch = $0A ''\LF\'' '''then'''
'''begin'''
ChOut(1, Ch); '''quit''';
'''end''';
Ch:= ChIn(1);
'''end'''
'''else''' '''if''' Ch&gt;=^a &amp; Ch&lt;=^z '''then''' ''\pass key words to output''
'''begin'''
Text(0, "&apos;&apos;&apos;"); ''\in bold''
'''while''' Ch&gt;=^a &amp; Ch&lt;=^z '''do'''
'''begin'''
ChOut(1, Ch); Ch:= ChIn(1);
'''end''';
Text(0, "&apos;&apos;&apos;");
'''end'''
'''else''' '''begin''' ''\pass anything else''
'''repeat''' CharOut(Ch);
Ch:= ChIn(1);
'''until''' Ch &lt;= $20; ''\until whitespace''
'''end''';
'''end''';
'''end'''
9,488

edits