Example #1
0
        private bool P_ArrayStmt(bool isProc)
        {
            if (P_Array())
            {
                if (P_VarName(out var arrName))
                {
                    if (P_LeftBracket())
                    {
                        if (P_PosOrNeg(out var num))
                        {
                            if (int.TryParse(num.Lex, out var lbound))
                            {
                                if (P_Dot() && P_Dot())
                                {
                                    if (P_PosOrNeg(out num))
                                    {
                                        if (int.TryParse(num.Lex, out var rbound))
                                        {
                                            var arrData = new PArray.ArrayData(lbound, rbound);
                                            var arr     = new PArray(arrName?.Lex, arrData);
                                            _arrs.Add(arr);
                                            P_ArrayList(arr);
                                            _arrCtr++;
                                            _bss.Add(new BssData($"arr_{_arrCtr}_{arrName?.Lex}", arrName?.Lex, "resb",
                                                                 arr.ComputeAllocSpace().ToString(), AsmDataType.Array));
                                            return(P_Semicolon());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                LogError("Unexpected token in array declaration.");
            }

            return(false);
        }