Open PropGit opened 9 years ago
Here are the reserved words for the BS2 stamp with PBASIC 2.5. Sorry, this list doesn't include the types or each reserved word- you'll have to get that by calling GetReservedWord from the tokenizer on source code that contains the '{$STAMP BS2}
and '{$PBASIC 2.5}
directives.
Symbol Type
-------- ---------------
$STAMP etDirective
$PORT etDirective
$PBASIC etDirective
BS1 etTargetModule
BS2 etTargetModule
BS2E etTargetModule
BS2SX etTargetModule
BS2P etTargetModule
BS2PE etTargetModule
BS2PX etTargetModule
IN0 etVariable
IN1 etVariable
IN2 etVariable
IN3 etVariable
IN4 etVariable
IN5 etVariable
IN6 etVariable
IN7 etVariable
IN8 etVariable
IN9 etVariable
IN10 etVariable
IN11 etVariable
IN12 etVariable
IN13 etVariable
IN14 etVariable
IN15 etVariable
OUT0 etVariable
OUT1 etVariable
OUT2 etVariable
OUT3 etVariable
OUT4 etVariable
OUT5 etVariable
OUT6 etVariable
OUT7 etVariable
OUT8 etVariable
OUT9 etVariable
OUT10 etVariable
OUT11 etVariable
OUT12 etVariable
OUT13 etVariable
OUT14 etVariable
OUT15 etVariable
DIR0 etVariable
DIR1 etVariable
DIR2 etVariable
DIR3 etVariable
DIR4 etVariable
DIR5 etVariable
DIR6 etVariable
DIR7 etVariable
DIR8 etVariable
DIR9 etVariable
DIR10 etVariable
DIR11 etVariable
DIR12 etVariable
DIR13 etVariable
DIR14 etVariable
DIR15 etVariable
INA etVariable
INB etVariable
INC etVariable
IND etVariable
OUTA etVariable
OUTB etVariable
OUTC etVariable
OUTD etVariable
DIRA etVariable
DIRB etVariable
DIRC etVariable
DIRD etVariable
INL etVariable
INH etVariable
OUTL etVariable
OUTH etVariable
DIRL etVariable
DIRH etVariable
B0 etVariable
B1 etVariable
B2 etVariable
B3 etVariable
B4 etVariable
B5 etVariable
B6 etVariable
B7 etVariable
B8 etVariable
B9 etVariable
B10 etVariable
B11 etVariable
B12 etVariable
B13 etVariable
B14 etVariable
B15 etVariable
B16 etVariable
B17 etVariable
B18 etVariable
B19 etVariable
B20 etVariable
B21 etVariable
B22 etVariable
B23 etVariable
B24 etVariable
B25 etVariable
INS etVariable
OUTS etVariable
DIRS etVariable
W0 etVariable
W1 etVariable
W2 etVariable
W3 etVariable
W4 etVariable
W5 etVariable
W6 etVariable
W7 etVariable
W8 etVariable
W9 etVariable
W10 etVariable
W11 etVariable
W12 etVariable
CON etDeclaration
DATA etInstruction
VAR etDeclaration
FOR etInstruction
NEXT etInstruction
GOTO etInstruction
GOSUB etInstruction
RETURN etInstruction
IF etInstruction
BRANCH etInstruction
LOOKUP etInstruction
LOOKDOWN etInstruction
RANDOM etInstruction
READ etInstruction
WRITE etInstruction
PAUSE etInstruction
INPUT etInstruction
OUTPUT etInstruction
LOW etInstruction
HIGH etInstruction
TOGGLE etInstruction
REVERSE etInstruction
SEROUT etInstruction
SERIN etInstruction
PULSOUT etInstruction
PULSIN etInstruction
COUNT etInstruction
SHIFTOUT etInstruction
SHIFTIN etInstruction
RCTIME etInstruction
BUTTON etInstruction
PWM etInstruction
FREQOUT etInstruction
DTMFOUT etInstruction
XOUT etInstruction
DEBUG etInstruction
STOP etInstruction
NAP etInstruction
SLEEP etInstruction
END etInstruction
TO etInstruction
STEP etInstruction
THEN etInstruction
SQR etUnaryOp
ABS etUnaryOp
~ etUnaryOp
DCD etUnaryOp
NCD etUnaryOp
COS etUnaryOp
SIN etUnaryOp
HYP etBinaryOp
ATN etBinaryOp
& etBinaryOp
| etBinaryOp
^ etBinaryOp
MIN etBinaryOp
MAX etBinaryOp
+ etBinaryOp
- etBinaryOp
*/ etBinaryOp
* etBinaryOp
** etBinaryOp
// etBinaryOp
/ etBinaryOp
DIG etBinaryOp
<< etBinaryOp
>> etBinaryOp
REV etBinaryOp
=> etConditionalOp
>= etConditionalOp
<= etConditionalOp
=< etConditionalOp
= etConditionalOp
<> etConditionalOp
<> etConditionalOp
> etConditionalOp
< etConditionalOp
AND etConditionalOp
OR etConditionalOp
XOR etConditionalOp
NOT etConditionalOp
BIT etVariableType
NIB etVariableType
BYTE etVariableType
WORD etVariableType
BIT0 etVariableMod
BIT1 etVariableMod
BIT2 etVariableMod
BIT3 etVariableMod
BIT4 etVariableMod
BIT5 etVariableMod
BIT6 etVariableMod
BIT7 etVariableMod
BIT8 etVariableMod
BIT9 etVariableMod
BIT10 etVariableMod
BIT11 etVariableMod
BIT12 etVariableMod
BIT13 etVariableMod
BIT14 etVariableMod
BIT15 etVariableMod
LOWBIT etVariableMod
HIGHBIT etVariableMod
NIB0 etVariableMod
NIB1 etVariableMod
NIB2 etVariableMod
NIB3 etVariableMod
LOWNIB etVariableMod
HIGHNIB etVariableMod
BYTE0 etVariableMod
BYTE1 etVariableMod
LOWBYTE etVariableMod
HIGHBYTE etVariableMod
ASC etIOFormatter
STR etIOFormatter
REP etIOFormatter
SKIP etIOFormatter
WAITSTR etIOFormatter
WAIT etIOFormatter
NUM etIOFormatter
SNUM etIOFormatter
DEC etIOFormatter
DEC1 etIOFormatter
DEC2 etIOFormatter
DEC3 etIOFormatter
DEC4 etIOFormatter
DEC5 etIOFormatter
SDEC etIOFormatter
SDEC1 etIOFormatter
SDEC2 etIOFormatter
SDEC3 etIOFormatter
SDEC4 etIOFormatter
SDEC5 etIOFormatter
HEX etIOFormatter
HEX1 etIOFormatter
HEX2 etIOFormatter
HEX3 etIOFormatter
HEX4 etIOFormatter
SHEX etIOFormatter
SHEX1 etIOFormatter
SHEX2 etIOFormatter
SHEX3 etIOFormatter
SHEX4 etIOFormatter
IHEX etIOFormatter
IHEX1 etIOFormatter
IHEX2 etIOFormatter
IHEX3 etIOFormatter
IHEX4 etIOFormatter
ISHEX etIOFormatter
ISHEX1 etIOFormatter
ISHEX2 etIOFormatter
ISHEX3 etIOFormatter
ISHEX4 etIOFormatter
BIN etIOFormatter
BIN1 etIOFormatter
BIN2 etIOFormatter
BIN3 etIOFormatter
BIN4 etIOFormatter
BIN5 etIOFormatter
BIN6 etIOFormatter
BIN7 etIOFormatter
BIN8 etIOFormatter
BIN9 etIOFormatter
BIN10 etIOFormatter
BIN11 etIOFormatter
BIN12 etIOFormatter
BIN13 etIOFormatter
BIN14 etIOFormatter
BIN15 etIOFormatter
BIN16 etIOFormatter
SBIN etIOFormatter
SBIN1 etIOFormatter
SBIN2 etIOFormatter
SBIN3 etIOFormatter
SBIN4 etIOFormatter
SBIN5 etIOFormatter
SBIN6 etIOFormatter
SBIN7 etIOFormatter
SBIN8 etIOFormatter
SBIN9 etIOFormatter
SBIN10 etIOFormatter
SBIN11 etIOFormatter
SBIN12 etIOFormatter
SBIN13 etIOFormatter
SBIN14 etIOFormatter
SBIN15 etIOFormatter
SBIN16 etIOFormatter
IBIN etIOFormatter
IBIN1 etIOFormatter
IBIN2 etIOFormatter
IBIN3 etIOFormatter
IBIN4 etIOFormatter
IBIN5 etIOFormatter
IBIN6 etIOFormatter
IBIN7 etIOFormatter
IBIN8 etIOFormatter
IBIN9 etIOFormatter
IBIN10 etIOFormatter
IBIN11 etIOFormatter
IBIN12 etIOFormatter
IBIN13 etIOFormatter
IBIN14 etIOFormatter
IBIN15 etIOFormatter
IBIN16 etIOFormatter
ISBIN etIOFormatter
ISBIN1 etIOFormatter
ISBIN2 etIOFormatter
ISBIN3 etIOFormatter
ISBIN4 etIOFormatter
ISBIN5 etIOFormatter
ISBIN6 etIOFormatter
ISBIN7 etIOFormatter
ISBIN8 etIOFormatter
ISBIN9 etIOFormatter
ISBIN10 etIOFormatter
ISBIN11 etIOFormatter
ISBIN12 etIOFormatter
ISBIN13 etIOFormatter
ISBIN14 etIOFormatter
ISBIN15 etIOFormatter
ISBIN16 etIOFormatter
. etPeriod
? etQuestionMark
\ etBackslash
@ etAtSign
( etParentheses
) etParentheses
[ etBrackets
] etBrackets
CLS etConstant
HOME etConstant
BELL etConstant
BKSP etConstant
TAB etConstant
CR etConstant
UNITON etConstant
UNITOFF etConstant
UNITSOFF etConstant
LIGHTSON etConstant
DIM etConstant
BRIGHT etConstant
LSBFIRST etConstant
MSBFIRST etConstant
MSBPRE etConstant
LSBPRE etConstant
MSBPOST etConstant
LSBPOST etConstant
PIN etDeclaration
DO etInstruction
EXIT etInstruction
LOOP etInstruction
UNTIL etInstruction
WHILE etInstruction
#DEFINE etCCDirective
#ERROR etCCDirective
#IF etCCDirective
#THEN etCCDirective
ELSE etInstruction
ELSEIF etInstruction
#ELSE etCCDirective
ENDIF etInstruction
#ENDIF etCCDirective
SELECT etInstruction
#SELECT etCCDirective
CASE etInstruction
#CASE etCCDirective
ENDSELECT etInstruction
#ENDSELECT etCCDirective
ON etInstruction
DEBUGIN etInstruction
CRSRXY etConstant
CRSRLF etConstant
CRSRRT etConstant
CRSRUP etConstant
CRSRDN etConstant
LF etConstant
CLREOL etConstant
CLRDN etConstant
CRSRX etConstant
CRSRY etConstant
In the DScheme array (code in the first posting), the elements describe the formatting for particular types. For example:
{PBASIC, SynDirectiveCondCompile} '$0808080,$1000000,$01,1',
This indicates that the "PBASIC" style for "Conditional Compile Directives" is a font color of $808080, a background color of default ($1000000), a character style of bold ($01), and a case style of upper case (1).
The default is indicated by the MSB of the second value ($1000000), and means that the default color is used (instead of an overriding color set locally here). For the editor, the default font color is black and the default background color is white.
The character style can be plain ($00), bold ($01), italic ($04), or underline ($16). The PBASIC syntax style is always plain or bold for any give syntax element, but the existing editor allows the user to set their own style (a feature we can ignore until further notice).
The case style is probably the most odd (and maybe difficult/impossible to do in a reasonable time frame). It specifies whether the syntax element should have no change (0) applied to its character case, or be UPPER-CASED (1), lower cased (2), or Capitalized (3). The PBASIC syntax style is unchanged or UPPER-CASED for most syntax elements, and Capitalized for one of the elements.
NOTE: Case-modification is likely to be non-trivial. Case-modification is deferred to a later time. See Issue 85.
Here's a more clearly-defined set of syntax highlighting metrics for PBASIC.
Notes
Syntax Type ElementType Font Color Bg Color Font Style Case Style
------------------------ --------------- -------------- ------------- ---------- ----------
SynCommand etInstruction Blue $0000FF Default Plain Upper
SynComment Green $008000 Default Plain No Change
SynConstantBinary Default Default Plain No Change
SynConstantDecimal Default Default Plain No Change
SynConstantHexadecimal Default Default Plain No Change
SynConstantPredefined etConstant Purple $800080 Default Plain Upper
SynConstantString Red $FF0000 Default Plain No Change
SynDefault Black $000000 White $FFFFFF Plain No Change
SynOperatorBinary etBinaryOp Default Default Plain Upper
SynOperatorConditional etConditionalOp Default Default Plain Upper
SynOperatorUnary etUnaryOp Default Default Plain Upper
SynDeclaration etDeclaration Default Default Plain Upper
SynDirectiveCondCompile etCCDirective Gray $808080 Default Bold Upper
SynDirectiveEditor etDirective Teal $008080 Default Bold Upper
SynDirectiveTargetModule etTargetModule Teal $008080 Default Bold Upper
SynIOFormatter etIOFormatter Navy $000080 Default Plain Upper
SynSelectionMarkedBlock White $FFFFFF Navy $000080 Plain No Change
SynSelectionSearchMatch Lime $00FF00 Black $000000 Plain No Change
SynVariableModifier etVariableMod Default Default Plain Upper
SynVariablePredefined etVariable Purple $800080 Default Plain Upper
SynVariableType etVariableType Default Default Plain Capitalize
Here's some detail about PBASIC Syntax Styles.
As I said in our hangout, the reserved-word list (which includes every element that need be syntax highlighted) is a dynamic list that changes depending on the exact module (BS2, BS2e, BS2sx, etc.) as well as the version of the PBASIC Language (2.0 or 2.5) that the code is actually written for. The mode of operation for the app is to invoke the GetReservedWord function from the tokenizer, on the code that is visible in the App, to retrieve the proper reserved word list, then apply the syntax highlighting styles according to the defined types as specified in the reserved word list. This must happen every time the code in the visible editor is loaded or syntax checked, as well as any time the $STAMP or $PBASIC directives are automatically changed by the App.
Here's the enumerations and arrays defined in the BASIC Stamp Editor which help map the GetReservedWord's response to the styles and rules.
NOTE:
SynCommand
throughSynVariableType
are enumerated IDs representing syntax types. I didn't include that enumeration here because it's confusingly large since it's part of a bit preference setting enumerated set.The
DScheme
array is a two-dimensional array that defines the default syntax highlighting schemes for Plain Text, Simple, and PBASIC syntax schemes. Each of these are pre-defined so that customers can choose to use a plain, very "light" highlighting, or full syntax highlighting; however, we are only targeting PBASIC syntax highlighting at this time in this Chrome IDE project. Be sure to read the comments below as they relate to the hex and decimal values for each row of the default array. Note that each row has a comment (in curly braces { and }) that indicates the scheme and the element style.Note: the
ctsInstruction
,tsComment
, etc. values are ordinals that represent (align to) the values delivered by the tokenizer's GetReservedWord functionHere's some code that registers custom parsers or certain types of elements. Not sure this code is helpful at all because it related directly to the low-level parser that I used in the original editor, but here it is anyway in case a little information can be gleaned... like binary numbers start is %.