mirror of
https://github.com/irmen/prog8.git
synced 2025-01-11 13:29:45 +00:00
prepare parser to allow chained array indexing later
This commit is contained in:
parent
c3fbdf34ca
commit
525a9b5036
@ -317,9 +317,10 @@ private fun Prog8ANTLRParser.Assign_targetContext.toAst() : AssignTarget {
|
|||||||
is MemoryTargetContext ->
|
is MemoryTargetContext ->
|
||||||
AssignTarget(null, null, DirectMemoryWrite(directmemory().expression().toAst(), directmemory().toPosition()), toPosition())
|
AssignTarget(null, null, DirectMemoryWrite(directmemory().expression().toAst(), directmemory().toPosition()), toPosition())
|
||||||
is ArrayindexedTargetContext -> {
|
is ArrayindexedTargetContext -> {
|
||||||
val arrayvar = scoped_identifier().toAst()
|
val ax = arrayindexed()
|
||||||
val index = arrayindex().toAst()
|
val arrayvar = ax.scoped_identifier().toAst()
|
||||||
val arrayindexed = ArrayIndexedExpression(arrayvar, index, scoped_identifier().toPosition())
|
val index = ax.arrayindex().toAst()
|
||||||
|
val arrayindexed = ArrayIndexedExpression(arrayvar, index, ax.toPosition())
|
||||||
AssignTarget(null, arrayindexed, null, toPosition())
|
AssignTarget(null, arrayindexed, null, toPosition())
|
||||||
}
|
}
|
||||||
else -> throw FatalAstException("weird assign target node $this")
|
else -> throw FatalAstException("weird assign target node $this")
|
||||||
@ -434,10 +435,11 @@ private fun Prog8ANTLRParser.ExpressionContext.toAst() : Expression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(arrayindex()!=null) {
|
if(arrayindexed()!=null) {
|
||||||
val identifier = scoped_identifier().toAst()
|
val ax = arrayindexed()
|
||||||
val index = arrayindex().toAst()
|
val identifier = ax.scoped_identifier().toAst()
|
||||||
return ArrayIndexedExpression(identifier, index, scoped_identifier().toPosition())
|
val index = ax.arrayindex().toAst()
|
||||||
|
return ArrayIndexedExpression(identifier, index, ax.toPosition())
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scoped_identifier()!=null)
|
if(scoped_identifier()!=null)
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
- prefix prog8 subroutines with p8s_ instead of p8_ to not let them clash with variables in the asm?
|
|
||||||
- allow 'chained' array indexing for expressions: value = ptrarray[0][0]
|
- prefix prog8 subroutines with p8s_ instead of p8_ to not let them clash with variables in the asm??
|
||||||
- allow 'chained' array indexing for assign targets: ptrarray[0][0] = 42 this is just evaluating the lhs as a uword pointer expression
|
|
||||||
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
||||||
- IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction
|
- IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction
|
||||||
- IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified!
|
- IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? etc), but only after setting the status bits is verified!
|
||||||
@ -21,6 +20,9 @@ Future Things and Ideas
|
|||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
Compiler:
|
Compiler:
|
||||||
|
|
||||||
|
- allow 'chained' array indexing for expressions: value = ptrarray[0][0]
|
||||||
|
- allow 'chained' array indexing for assign targets: ptrarray[0][0] = 42 this is just evaluating the lhs as a uword pointer expression
|
||||||
|
|
||||||
- [much work:] more support for (64tass) SEGMENTS ?
|
- [much work:] more support for (64tass) SEGMENTS ?
|
||||||
- (What, how, isn't current BSS support enough?)
|
- (What, how, isn't current BSS support enough?)
|
||||||
- Add a mechanism to allocate variables into golden ram (or segments really) (see GoldenRam class)
|
- Add a mechanism to allocate variables into golden ram (or segments really) (see GoldenRam class)
|
||||||
|
@ -153,7 +153,7 @@ augassignment :
|
|||||||
|
|
||||||
assign_target:
|
assign_target:
|
||||||
scoped_identifier #IdentifierTarget
|
scoped_identifier #IdentifierTarget
|
||||||
| scoped_identifier arrayindex #ArrayindexedTarget // TODO expression instead of just scoped_identifier
|
| arrayindexed #ArrayindexedTarget
|
||||||
| directmemory #MemoryTarget
|
| directmemory #MemoryTarget
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -180,12 +180,18 @@ expression :
|
|||||||
| left = expression EOL? bop = 'xor' EOL? right = expression
|
| left = expression EOL? bop = 'xor' EOL? right = expression
|
||||||
| literalvalue
|
| literalvalue
|
||||||
| scoped_identifier
|
| scoped_identifier
|
||||||
| scoped_identifier arrayindex // TODO expression instead of just scoped_identifier
|
| arrayindexed
|
||||||
| directmemory
|
| directmemory
|
||||||
| addressof
|
| addressof
|
||||||
| expression typecast
|
| expression typecast
|
||||||
;
|
;
|
||||||
|
|
||||||
|
arrayindexed:
|
||||||
|
scoped_identifier arrayindex
|
||||||
|
// TODO to allow chained array indexing: | arrayindexed arrayindex
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
typecast : 'as' datatype;
|
typecast : 'as' datatype;
|
||||||
|
|
||||||
directmemory : '@' '(' expression ')';
|
directmemory : '@' '(' expression ')';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user