📄 gram.y
字号:
} } | domain REG arch_reg '=' HEX { SHOWPARSE("=== stmt -> domain REG arch_reg = HEX\n"); uint32_t valueLen = strlen($5.str() - 2); if (valueLen > $3->len * 2) { Diag::printf("%s:%d: value \"%s\" exceeds " "register size.\n", current_file.str(), current_line, $5.str()); num_errors++; YYERROR; } $3->WriteValue(image, $1, $5); } ;qualified_key: qualifier key { if ( !QualifyKey($1, $2, $$) ) { SHOWPARSE("--- !QualifyKey\n"); num_errors++; YYERROR; } } ;key: NULLKEY { SHOWPARSE("=== key -> NULLKEY\n"); Diag::printf("%s:%d: null key should often be replaced by " "void key! \"%s\"\n", current_file.str(), current_line); $$ = NumberKey(0); } | VOIDKEY { SHOWPARSE("=== key -> VOIDKEY\n"); $$ = MiscKey(KT_Void); } | VOLSIZE { SHOWPARSE("=== key -> VOLSIZE \n"); OID oid = 0x0; $$ = NodeKey(oid); } | NUMBER '(' string_lit ')' { SHOWPARSE("=== key -> NUMBER ( STRING )\n"); $$ = NumberFromString($3) } | NUMBER '(' arith_expr ')' { SHOWPARSE("=== key -> NUMBER ( arith_expr )\n"); $$ = NumberKey($3); } | NUMBER '(' arith_expr ',' arith_expr ',' arith_expr ')' { SHOWPARSE("=== key -> NUMBER ( arith_expr , arith_expr , arith_expr )\n"); $$ = NumberKey($3, $5, $7); } | RANGE '(' oid ':' oid ')' { SHOWPARSE("=== key -> RANGE ( oid : oid )\n"); $$ = RangeKey($3, $5); } | PRIME RANGE { SHOWPARSE("=== key -> PRIME RANGE\n"); $$ = MiscKey(KT_PrimeRange); } | PHYSMEM RANGE { SHOWPARSE("=== key -> PHYSMEM RANGE\n"); $$ = MiscKey(KT_PhysRange); } | SCHED '(' priority ')' { SHOWPARSE("=== key -> SCHED ( priority )\n"); $$ = SchedKey($3); } | MISC MISC_KEYNAME { SHOWPARSE("=== key -> MISC NAME\n"); uint32_t miscType; if (GetMiscKeyType($2, miscType) == false) { Diag::printf("%s:%d: unknown misc key type \"%s\"\n", current_file.str(), current_line, $2.str()); num_errors++; YYERROR; } $$ = MiscKey(miscType); } | MISC_KEYNAME { SHOWPARSE("=== key -> MISC_KEYNAME\n"); uint32_t miscType; if (GetMiscKeyType($1, miscType) == false) { Diag::printf("%s:%d: unknown misc key type \"%s\"\n", current_file.str(), current_line, $1.str()); num_errors++; YYERROR; } $$ = MiscKey(miscType); } | segtype string_lit { SHOWPARSE("=== key -> segtype STRING\n"); DiskKey key; if ( !AddRawSegment(image, $2, key) ) { num_errors++; YYERROR; } if ($1) key.SetType(KT_Segment); $$ = key; } | SYMBOL string_lit NAME { SHOWPARSE("=== key -> STRING NAME\n"); uint32_t new_pc; DiskKey key; if ( GetProgramSymbolValue($2, $3, new_pc) ) { key = NumberKey(new_pc); } else { Diag::printf("%s:%d: Image \"%s\" did not have symbol \"%s\"\n", $2.str(), $3.str()); num_errors++; YYERROR; } $$ = key; } | PROGRAM segtype string_lit { SHOWPARSE("=== key -> = PROGRAM segtype STRING\n"); DiskKey key; if (! AddProgramSegment(image, $3, key) ) { num_errors++; YYERROR; } if ($2) { if ( key.IsType(KT_Page) ) { DiskKey segKey = image.AddNode(); segKey.SetBlss(key.GetBlss() + 1); segKey.InitType(KT_Segment); segKey.SetUnprepared(); image.SetNodeSlot(segKey, 0, key); key = segKey; } key.SetType(KT_Segment); } $$ = key; } | SMALL PROGRAM string_lit { SHOWPARSE("=== key -> SMALL PROGRAM string_lit\n"); DiskKey key; if (! AddProgramSegment(image, $3, key) ) { num_errors++; YYERROR; } if (key.GetBlss() > (EROS_PAGE_BLSS + 1)) { Diag::printf("%s:%d: binary image too large for small program\n", current_file.str(), current_line); num_errors++; YYERROR; } if ( key.IsType(KT_Page) ) { DiskKey segKey = image.AddNode(); segKey.SetBlss(key.GetBlss() + 1); image.SetNodeSlot(segKey, 0, key); key = segKey; } $$ = key; } | ZERO segtype WITH arith_expr PAGES { SHOWPARSE("=== key -> ZERO segtype WITH arith_expr PAGES\n"); DiskKey key; if ( !AddZeroSegment(image, key, $4) ) { num_errors++; YYERROR; } if ($2) key.SetType(KT_Segment); $$ = key; } | EMPTY segtype WITH arith_expr PAGES { SHOWPARSE("=== key -> EMPTY segtype WITH arith_expr PAGES\n"); DiskKey key; if ( !AddEmptySegment(image, key, $4) ) { num_errors++; YYERROR; } if ($2) key.SetType(KT_Segment); $$ = key; } | RED segtype WITH blss {#ifdef KT_Wrapper Diag::printf("%s:%d: red segments now obsolete!\n", current_file.str(), current_line); num_errors++; YYERROR;#else SHOWPARSE("=== key -> RED segtype WITH blss\n"); DiskKey key; key = image.AddNode(); /* Fabricate format key with 13 initial slots, normal (node key) invocation convention, no background key or keeper key. */ DiskKey fmtKey = NumberKey(0); REDSEG_SET_INITIAL_SLOTS(fmtKey.nk, EROS_NODE_SIZE-3); REDSEG_SET_RESERVED_SLOTS(fmtKey.nk, EROS_NODE_SIZE-1); REDSEG_SET_BLSS(fmtKey.nk, $4); image.SetNodeSlot(key, RedSegFormat, fmtKey); image.SetNodeSlot(key, RedSegBackground, VoidDiskKey()); /* for clarity; should already be void */ if ($2) key.SetType(KT_Segment); key.SetBlss(RedSegBLSS); $$ = key;#endif } | WRAPPER WITH blss {#ifdef KT_Wrapper SHOWPARSE("=== key -> WRAPPER WITH blss\n"); DiskKey key; key = image.AddNode(); /* Fabricate format key with 13 initial slots, normal (node key) invocation convention, no background key or keeper key. */ DiskKey fmtKey = NumberKey(0); WRAPPER_SET_BLSS(fmtKey.nk, $3); image.SetNodeSlot(key, WrapperFormat, fmtKey); image.SetNodeSlot(key, WrapperBackground, VoidDiskKey()); /* for clarity; should already be void */ key.SetType(KT_Wrapper); $$ = key;#else Diag::printf("%s:%d: kernel does not support wrapper nodes!\n", current_file.str(), current_line); num_errors++; YYERROR;#endif } | NEW qualifier NODE { SHOWPARSE("=== key -> NEW qualifier NODE\n"); DiskKey key = image.AddNode(); SHOWPARSE("Reduce key -> NEW qualifier NODE\n"); if ( !QualifyKey($2, key, key) ) { num_errors++; YYERROR; } $$ = key; } | NEW qualifier RED NODE { SHOWPARSE("=== key -> NEW qualifier RED NODE\n"); DiskKey key = image.AddNode(); key.SetBlss(BLSS::RedSeg); image.SetNodeSlot(key, RedSegFormat, NumberKey(0)); SHOWPARSE("Reduce key -> NEW qualifier RED NODE\n"); if ( !QualifyKey($2, key, key) ) { num_errors++; YYERROR; } $$ = key; } | NEW qualifier WRAPPER {#ifdef KT_Wrapper SHOWPARSE("=== key -> NEW qualifier WRAPPER\n"); DiskKey key = image.AddNode(); SHOWPARSE("Reduce NAME = qualifier WRAPPER\n"); if ( !QualifyKey($2, key, key) ) { num_errors++; YYERROR; } DiskKey fmtKey = NumberKey(0); image.SetNodeSlot(key, WrapperFormat, fmtKey); key.SetType(KT_Wrapper); $$ = key;#else Diag::printf("%s:%d: kernel does not support wrapper nodes!\n", current_file.str(), current_line); num_errors++; YYERROR;#endif } | NEW qualifier PAGE { SHOWPARSE("=== key -> NEW qualifier PAGE\n"); DiskKey key = image.AddZeroDataPage(); if ( !QualifyKey($2, key, key) ) { num_errors++; YYERROR; } $$ = key; } | NAME { SHOWPARSE("=== key -> NAME\n"); DiskKey key; if (image.GetDirEnt($1, key) == false) { Diag::printf("%s:%d: unknown object \"%s\"\n", current_file.str(), current_line, $1.str()); num_errors++; YYERROR; } $$ = key; } | CLONE node { SHOWPARSE("=== key -> CLONE key\n"); DiskKey nodeKey = $2; DiskKey key = image.AddNode(); for (uint32_t i = 0; i < EROS_NODE_SIZE; i++) { DiskKey tmp = image.GetNodeSlot(nodeKey, i); image.SetNodeSlot(key, i, tmp); } /* Patch the resulting key so that the permissions and type * match those of the incoming key: */ key.keyType = nodeKey.keyType; key.keyFlags = nodeKey.keyFlags; key.keyData = nodeKey.keyData; $$ = key; } | key WITH blss { SHOWPARSE("=== key -> key NAME blss\n"); DiskKey key = $1; /* if (image.GetDirEnt($1, key) == false) { Diag::printf("%s:%d: unknown object \"%s\"\n", current_file.str(), current_line, $1.str()); num_errors++; YYERROR; } */ if (key.IsSegModeType() == false) { Diag::printf("%s:%d: can only set BLSS on segmode keys\n", current_file.str(), current_line); num_errors++; YYERROR; } key.SetBlss($3); key.SetType((KeyType)$1.GetType()); $$ = key; } | key WITH CONSTITUENTS { SHOWPARSE("=== key -> key WITH CONSTITUENTS\n"); DiskKey rootKey = $1; if (rootKey.IsType(KT_Process) == false) { Diag::printf("%s:%d: can only add constituents to a process\n", current_file.str(), current_line); num_errors++; YYERROR; } DiskKey keyRegsKey = image.GetNodeSlot(rootKey, ProcGenKeys); DiskKey constituents = image.AddNode(); constituents.SetBlss(EROS_PAGE_BLSS); constituents.SetReadOnly(); image.SetNodeSlot(keyRegsKey, KR_CONSTIT, constituents); $$ = rootKey; } | key AS qualifier SEGMENT KEY { SHOWPARSE("=== key -> key AS SEGMENT KEY\n"); DiskKey key = $1; if (key.IsSegModeType() == false) { Diag::printf("%s:%d: can only retype segmode keys\n", current_file.str(), current_line); num_errors++; YYERROR; } key.SetType(KT_Segment); if ( !QualifyKey($3, key, key) ) { num_errors++; YYERROR; } $$ = key; } | key AS qualifier WRAPPER KEY {#ifdef KT_Wrapper SHOWPARSE("=== key -> key AS WRAPPER KEY\n"); DiskKey key = $1; if (key.IsSegModeType() == false) { Diag::printf("%s:%d: can only retype segmode keys\n", current_file.str(), current_line); num_errors++; YYERROR; } key.SetType(KT_Wrapper); if ( !QualifyKey($3, key, key) ) { num_errors++; YYERROR; } $$ = key;#else Diag::printf("%s:%d: kernel does not support wrapper nodes!\n", current_file.str(), current_line); num_errors++; YYERROR;#endif } | key AS qualifier NODE KEY { SHOWPARSE("=== key -> key AS NODE KEY\n"); DiskKey key = $1; if (key.IsSegModeType() == false) { Diag::printf("%s:%d: can only retype segmode keys\n", current_file.str(), current_line); num_errors++; YYERROR; } key.SetType(KT_Node); if ( !QualifyKey($3, key, key) ) { num_errors++; YYERROR; } $$ = key; } | key WITH qualifier PAGE AT offset { SHOWPARSE("=== key -> qualifier NAME with page_qualifier PAGE AT offset\n"); DiskKey key = $1; /* if (image.GetDirEnt($1, key) == false) { Diag::printf("%s:%d: unknown object \"%s\"\n", current_file.str(), current_line, $1.str()); num_errors++; YYERROR; } */ if (key.IsSegModeType() == false) { Diag::printf("%s:%d: can only add pages to segments!\n", current_file.str(), current_line); num_errors++; YYERROR; } DiskKey pageKey = image.AddZeroDataPage($3 & (ATTRIB_RO) ? true : false); uint64_t offset = $6; { uint32_t segOffsetBLSS = LSS::BiasedLSS(offset); uint32_t rootBLSS = key.GetBlss(); uint32_t segBLSS = pageKey.GetBlss(); if (segOffsetBLSS <= segBLSS && rootBLSS <= segOffsetBLSS) { Diag::printf("%s:%d: Inserted page and offset would " "replace existing segment.\n", current_file.str(), current_line); num_errors++; YYERROR; } } key = image.AddPageToSegment(key, offset, pageKey); $$ = key; } | key WITH qualifier SUBSEG segkey AT offset { SHOWPARSE("=== key -> qualifier NAME with qualifier SUBSEG AT offset\n"); DiskKey key = $1; /* if (image.GetDirEnt($1, key) == false) { Diag::printf("%s:%d: unknown object \"%s\"\n", current_file.str(), current_line, $1.str()); num_errors++; YYERROR; } */ if (key.IsSegModeType() == false) { Diag::printf("%s:%d: can only add subsegments to segments!\n", current_file.str(), current_line); num_errors++; YYERROR; } DiskKey subSeg = $5; if (subSeg.IsSegModeType() == false) { Diag::printf("%s:%d: qualifiers only permitted on" " segmode keys\n", current_file.str(), current_line); num_errors++; YYERROR; } uint64_t offset = $7; { uint32_t segOffsetBLSS = LSS::BiasedLSS(offset); uint32_t rootBLSS = key.GetBlss(); uint32_t segBLSS = subSeg.GetBlss(); if (segOffsetBLSS <= segBLSS && rootBLSS <= segOffsetBLSS) { Diag::printf("%s:%d: Inserted segment and offset would " "replace existing segment.\n", current_file.str(), current_line); num_errors++; YYERROR; } } if ( !QualifyKey($3, subSeg, subSeg) ) { num_errors++; YYERROR; } key = image.AddSubsegToSegment(key, offset, subSeg); $$ = key; } | NEW DOMAIN { SHOWPARSE("=== key -> NEW DOMAIN\n"); Diag::warning("%s:%d: Obsolete syntax 'new domain', use 'new process'\n", current_file.str(), current_line); DiskKey key = image.AddProcess(); RegDescrip::InitProcess(image, key, CurArch); key.SetType(KT_Process); $$ = key; } | NEW PROCESS { SHOWPARSE("=== key -> NEW PROCESS\n"); DiskKey key = image.AddProcess(); RegDescrip::InitProcess(image, key, CurArch); key.SetType(KT_Process); $$ = key; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -