Skip to content

Commit

Permalink
Lots of parser cleanup - see changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsheep committed Mar 16, 2021
1 parent 51490dc commit 5feaeff
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 138 deletions.
18 changes: 10 additions & 8 deletions spin2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Possible next additions:
- Add new-file templates as Snippets
- Add additional Snippets as the community identifies them

## [0.3.3] 2021-03-??
## [0.3.3] 2021-03-16
4th Release of Semantic Highlighting

This represents further improvement in parsing
This represents a noticeable cleanup of parsing most existing code.

### - What's new

Expand All @@ -37,10 +37,14 @@ Semantic Adjustments:
- Update: VAR declarations - parses all examples in spin2 doc
- Update: CON declarations - parses all examples in spin2 doc
- Update: parses all examples shipped with PNut (less `Spin2_interpreter.spin2`)
- Addition: if variables are used but not (yet?) defined they'll be shown in RED
- Update: now parses most of the P2 OBEX cleanly... still more to do tho'
- NEW: if variables are used but not (yet?) defined they'll be shown in RED
- BUGFIX: no longer marking vars within `{ }` single line comments
- BUGFIX: now handles multi-line enum declarations
- BUGFIX: now handles comma-delimited constant assignments
- BUGFIX: most if not all embedded assignment (e.g., `until ((b := rxcheck()) >= 0)`) now correct
- BUGFIX: most if not all shorter variable highlight is now working
- BUGFIX: multiple assignment LHS of := now highlighted correctly

Syntax Adjustments:

Expand All @@ -50,16 +54,14 @@ Syntax Adjustments:
- BUGFIX add missing `clkfreq_`, `_clkfreq` constant
- BUGFIX add missing `FVAR`, `FVARS` overrides
- BUGFIX add missing `REG`, `AND` operators
- BUGFIX add missing spin built-ins `getms()`, `QSIN()`, `QCOS()`
- BUGFIX add missing spin built-ins `getms()`, `QSIN()`, `QCOS()`, `PINC()`
- BUGFIX adjusted pub/pri to allow space before open paren

### - Known Issues w/v0.3.2
### - Known Issues w/v0.3.3
- Pasm: doesn't recognize round(), float(), and trunc() as pasm operand
- Spin: Badly handles embedded assignment (e.g., `until ((b := rxcheck()) >= 0)`)
- Spin: Badly handles marking multiple vars LHS of assignment
- Spin: Badly handles strings (should be ignoring contents of them)
- Incorrectly colors **built-in** constants (should be own color)
- Fails to parse some debug() statements correctly
- Fails to properly identify location of shorter variable name when is found within longer name earler in line...
- Syntax highlight of DAT section sometimes fails... RES and FIT not colored correctly
- Semantic highlight: the 'modification' attribute is being over-applied
- Semantic highlight: the 'modification' attribute should use more than := as test!!!!
Expand Down
71 changes: 50 additions & 21 deletions spin2/TEST/docs-spin2-language.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,26 @@ pub something()
varName = INB

DAT
varName mov a,IJMP3
varName mov a,IRET3
varName mov a,IJMP2
varName mov a,IRET2
varName mov a,IJMP1
varName mov a,IRET1

varName mov a,PA
varName mov a,PB
varName mov a,PTRA
varName mov a,PTRB

varName mov a,DIRA
varName mov a,DIRB
varName mov a,OUTA
varName mov a,OUTB
varName mov a,INA
varName mov a,INB

varName mov a7,IJMP3
varName mov a7,IRET3
varName mov a7,IJMP2
varName mov a7,IRET2
varName mov a7,IJMP1
varName mov a7,IRET1

varName mov a7,PA
varName mov a7,PB
varName mov a7,PTRA
varName mov a7,PTRB

varName mov a7,DIRA
varName mov a7,DIRB
varName mov a7,OUTA
varName mov a7,OUTB
varName mov a7,INA
varName mov a7,INB

a7 long 0

' -----------------------------------------------------------------------------
'' Pin Fields - Spin2 Pg 7
Expand Down Expand Up @@ -181,7 +182,6 @@ pub built_in_Methods4(RegOrHubAddr, HubAddr)

pub built_in_Methods5(x, y, angle32bit, length, angle, twopi, mult1, mult2, divisor) | x, y, rotx, roty, quotient, Rnd
'' Math Methods
' TODO: multi-return value not colored correctly!
rotx, roty := ROTXY(x, y, angle32bit)
x, y := POLXY(length, angle32bit)
length, angle32bit := XYPOL(x, y)
Expand Down Expand Up @@ -227,7 +227,7 @@ pub using_methods1(ToStr, FromStr) | x
x := GETRND() +// 100 'Get a random number between 0 and 99
BYTEMOVE(ToStr, FromStr, STRSIZE(FromStr) + 1)

pub using_methods2(ToStr, FromStr, rho1, rho2, theta1, theta2, xin, yin, theta) | x
pub using_methods2(ToStr, FromStr, rho1, rho2, theta1, theta2, xin, yin, theta) | x, y
'' Methods that return single results
x,y := SumPoints(POLXY(rho1,theta1), POLXY(rho2,theta2))

Expand Down Expand Up @@ -257,3 +257,32 @@ PRI Sub3() | ErrorCode ' Sub3 ABORTs, returning to Sub1 with ErrorCode
ErrorCode := -1
ABORT ErrorCode ' ABORT and return ErrorCode
PINLOW(0) ' PINLOW never executes

' -----------------------------------------------------------------------------
'' Using Methods - Spin2 Pg 7
' -----------------------------------------------------------------------------
pub using_methods3(register, index, address, bitfield) | AnyVar

AnyVar ' Hub or permanent register variable
HubVar.WORD ' Hub variable with BYTE/WORD/LONG size override
BYTE[address] ' Hub BYTE/WORD/LONG by address
REG[register] ' Register, 'register' may be symbol declared in ORG section

AnyVar[index] ' Hub or permanent register variable with index
HubVar.BYTE[index] ' Hub variable with size override and index
LONG[address][index] ' Hub BYTE/WORD/LONG by address with index
REG[register][index] ' Register with index

AnyVar.[bitfield] ' Hub or permanent register variable with bitfield
HubVar.LONG.[bitfield] ' Hub variable with size override and bitfield
WORD[address].[bitfield] ' Hub BYTE/WORD/LONG by address with bitfield
REG[register].[bitfield] ' Register with bitfield

AnyVar[index].[bitfield] ' Hub or permanent register variable with index and bitfield
HubVar.BYTE[index].[bitfield] ' Hub variable with size override, index, and bitfield
LONG[address][index].[bitfield] ' Hub BYTE/WORD/LONG by address with index and bitfield
REG[register][index].[bitfield] ' Register with index and bitfield

dat
ORGH
HubVar long 0
5 changes: 2 additions & 3 deletions spin2/spin2.language-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
["\"", "\""]
],
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)"
}
}
Loading

0 comments on commit 5feaeff

Please sign in to comment.