g|on苹果手机ll是什么版本手机

当前位置: &
求翻译:onll chan是什么意思?
问题补充:
我来回答:
参考资料:
* 验证码:
登录后回答可以获得积分奖励,并可以查看和管理所有的回答。 |
我要翻译和提问
请输入您需要翻译的文本!From Wikipedia, the free encyclopedia
In , an LL parser is a
for a subset of . It parses the input from Left to right, performing
of the sentence.
An LL parser is called an LL(k) parser if it uses k
when parsing a sentence. If such a parser exists for a certain grammar and it can parse sentences of this grammar without
then it is called an LL(k) grammar. LL(k) grammars can generate more languages the higher the number k of lookahead tokens. A corollary of this is that not all context-free languages can be recognized by an LL(k) parser. An LL parser is called an LL(*) parser (an LL-regular parser) if it is not restricted to a finite k tokens of lookahead, but can make parsing decisions by recognizing whether the following tokens belong to a
(for example by means of a ).
LL grammars, particularly LL(1) grammars, are of great practical interest, as parsers for these grammars are easy to construct, and many
are designed to be LL(1) for this reason. LL parsers are table-based parsers, similar to . LL grammars can also be parsed by .
For a given , the parser attempts to find the . Given an example grammar
{\displaystyle G}
{\displaystyle S\to E}
{\displaystyle E\to (E+E)}
{\displaystyle E\to i}
the leftmost derivation for
{\displaystyle w=((i+i)+i)}
{\displaystyle S\ {\overset {(1)}{\Rightarrow }}\ E\ {\overset {(2)}{\Rightarrow }}\ (E+E)\ {\overset {(2)}{\Rightarrow }}\ ((E+E)+E)\ {\overset {(3)}{\Rightarrow }}\ ((i+E)+E)\ {\overset {(3)}{\Rightarrow }}\ ((i+i)+E)\ {\overset {(3)}{\Rightarrow }}\ ((i+i)+i)}
Generally, there are multiple possibilities when selecting a rule to expand given (leftmost) non-terminal. In the previous example of the leftmost derivation, in step 2:
{\displaystyle S\ {\overset {(1)}{\Rightarrow }}\ E\ {\overset {(?)}{\Rightarrow }}\ ?}
To be effective, the parser must be able to make this choice deterministically when possible, without backtracking. For some grammars, it can do this by peeking on the unread input (without reading). In our example, if the parser knows that the next unread symbol is
{\displaystyle (}
, the only correct rule that can be used is 2.
Generally,
{\displaystyle LL(k)}
parser can look ahead at
{\displaystyle k}
symbols. However, given a grammar, the problem of determining if there exists a
{\displaystyle LL(k)}
parser for some
{\displaystyle k}
that recognizes it is undecidable. For each
{\displaystyle k}
, there is a language that cannot be recognized by
{\displaystyle LL(k)}
parser, but can be by
{\displaystyle LL(k+1)}
We can use the above analysis to give the following formal definition:
{\displaystyle G}
be a context-free grammar and
{\displaystyle k\geq 1}
. We say that
{\displaystyle G}
{\displaystyle LL(k)}
, if and only if for any two leftmost derivations:
{\displaystyle S\ \Rightarrow \ \dots \ \Rightarrow \ wA\alpha \ \Rightarrow \ \dots \ \Rightarrow \ w\beta \alpha \ \Rightarrow \ \dots \ \Rightarrow \ wx}
{\displaystyle S\ \Rightarrow \ \dots \ \Rightarrow \ wA\alpha \ \Rightarrow \ \dots \ \Rightarrow \ w\gamma \alpha \ \Rightarrow \ \dots \ \Rightarrow \ wy}
Following condition holds: Prefix of the string
{\displaystyle x}
{\displaystyle k}
equals the prefix of the
{\displaystyle y}
{\displaystyle k}
{\displaystyle \beta \ =\ \gamma }
In this definition,
{\displaystyle S}
is the starting and
{\displaystyle A}
any non-terminal. The already derived input
{\displaystyle w}
, and yet unread
{\displaystyle x}
{\displaystyle y}
are strings of terminals. The Greek letters
{\displaystyle \alpha }
{\displaystyle \beta }
{\displaystyle \gamma }
represent any string of both terminals and non-terminals (possibly empty). The prefix length corresponds to the lookahead buffer size, and the definition says that this buffer is enough to distinguish between any two derivations of different words.
{\displaystyle LL(k)}
parser is a
with the ability to peek on the next
{\displaystyle k}
input symbols without reading. This capability can be emulated by storing the lookahead buffer contents in the finite state space, since both buffer and input alphabet are finite in size. As a result, this does not make the automaton more powerful, but is a convenient abstraction.
The stack alphabet
{\displaystyle \Gamma =N\cup \Sigma }
{\displaystyle N}
is the set of non-
{\displaystyle \Sigma }
the set of terminal (input) symbols with a special end-of-input (EOI) symbol
{\displaystyle \$}
The parser stack initially contains the starting symbol above the EOI:
{\displaystyle [\ S\ \$\ ]}
. During operation, the parser repeatedly replaces the symbol
{\displaystyle X}
on top of the stack:
{\displaystyle \alpha }
{\displaystyle X\in N}
and there is a rule
{\displaystyle X\to \alpha }
{\displaystyle \epsilon }
(in some notations
{\displaystyle \lambda }
{\displaystyle X}
is popped off the stack, if
{\displaystyle X\in \Sigma }
. In this case, an input symbol
{\displaystyle x}
is read and if
{\displaystyle x\neq X}
, the parser rejects the input.
If the last symbol to be removed from the stack is the EOI, the p the automaton accepts via an empty stack.
The states and the transition function are
they are specified (generated) using a more convenient parse table instead. The table provides the following mapping:
row: top-of-stack symbol
{\displaystyle X}
{\displaystyle |w|\leq k}
lookahead buffer contents
cell: rule number for
{\displaystyle X\to \alpha }
{\displaystyle \epsilon }
If the parser cannot perform a valid transition, the input is rejected (empty cells). To make the table more compact, only the non-terminal rows are commonly displayed, since the action is the same for terminals.
To explain an LL(1) parser's workings we will consider the following small LL(1) grammar:
S → ( S + F )
and parse the following input:
We construct a parsing table for this grammar by expanding all the terminals by column and all nonterminals by row. Later, the expressions are numbered by the position where the columns and rows cross. For example, the terminal '(' and non-terminal 'S' match for expression number 2. The table is as follows:
(Note that there is also a column for the special terminal, represented here as $, that is used to indicate the end of the input stream.)
In each step, the parser reads the next-available symbol from the input stream, and the top-most symbol from the stack. If the input symbol and the stack-top symbol match, the parser discards them both, leaving only the unmatched symbols in the input stream and on the stack.
Thus, in its first step, the parser reads the input symbol '(' and the stack-top symbol 'S'. The parsing table instruction comes from the column headed by the input symbol '(' and the row headed by the stack-top symbol 'S'; this cell contains '2', which instructs the parser to apply rule (2). The parser has to rewrite 'S' to '( S + F )' on the stack by removing 'S' from stack and pushing ')', 'F', '+', 'S', '(' onto the stack and this writes the rule number 2 to the output. The stack then becomes:
[ (, S, +, F, ), $ ]
Since the '(' from the input stream did not match the top-most symbol, 'S', from the stack, it was not removed, and remains the next-available input symbol for the following step.
In the second step, the parser removes the '(' from its input stream and from its stack, since they now match. The stack now becomes:
[ S, +, F, ), $ ]
Now the parser has an 'a' on its input stream and an 'S' as its stack top. The parsing table instructs it to apply rule (1) from the grammar and write the rule number 1 to the output stream. The stack becomes:
[ F, +, F, ), $ ]
The parser now has an 'a' on its input stream and an 'F' as its stack top. The parsing table instructs it to apply rule (3) from the grammar and write the rule number 3 to the output stream. The stack becomes:
[ a, +, F, ), $ ]
In the next two steps the parser reads the 'a' and '+' from the input stream and, since they match the next two items on the stack, also removes them from the stack. This results in:
[ F, ), $ ]
In the next three steps the parser will replace 'F' on the stack by 'a', write the rule number 3 to the output stream and remove the 'a' and ')' from both the stack and the input stream. The parser thus ends with '$' on both its stack and its input stream.
In this case the parser will report that it has accepted the input string and write the following list of rule numbers to the output stream:
[ 2, 1, 3, 3 ]
This is indeed a list of rules for a
of the input string, which is:
S → ( S + F ) → ( F + F ) → ( a + F ) → ( a + a )
Below follows a C++ implementation of a table-based LL parser for the example language:
#include &iostream&
#include &map&
#include &stack&
enum Symbols {
// the symbols:
// Terminal symbols:
TS_L_PARENS, // (
TS_R_PARENS, // )
TS_PLUS, // +
// $, in this case corresponds to '\0'
TS_INVALID, // invalid token
// Non-terminal symbols:
Converts a valid token to the corresponding terminal symbol
Symbols lexer(char c)
return TS_L_PARENS;
return TS_R_PARENS;
return TS_A;
return TS_PLUS;
case '\0': return TS_EOS; // end of stack: the $ terminal symbol
return TS_INVALID;
int main(int argc, char **argv)
using namespace std;
if (argc & 2)
cout && "usage:\n\tll '(a+a)'" && endl;
// LL parser table, maps & non-terminal, terminal& pair to action
map& Symbols, map&Symbols, int& & table;
stack&Symbols& ss; // symbol stack
char *p; // input buffer
// initialize the symbols stack
ss.push(TS_EOS); // terminal, $
ss.push(NTS_S);
// non-terminal, S
// initialize the symbol stream cursor
p = &argv[1][0];
// set up the parsing table
table[NTS_S][TS_L_PARENS] = 2;
table[NTS_S][TS_A] = 1;
table[NTS_F][TS_A] = 3;
while(ss.size() & 0)
if(lexer(*p) == ss.top())
cout && "Matched symbols: " && lexer(*p) && endl;
cout && "Rule " && table[ss.top()][lexer(*p)] && endl;
switch(table[ss.top()][lexer(*p)])
case 1: // 1. S → F
ss.push(NTS_F); // F
case 2: // 2. S → ( S + F )
ss.push(TS_R_PARENS); // )
ss.push(NTS_F);
ss.push(TS_PLUS); // +
ss.push(NTS_S);
ss.push(TS_L_PARENS); // (
case 3: // 3. F → a
ss.push(TS_A); // a
cout && "parsing table defaulted" && endl;
cout && "finished parsing" && endl;
#All constants are indexed from 0
# Terminals
T_LPAR = 0
T_RPAR = 1
T_PLUS = 3
T_INVALID = 5
# Non-terminals
#parse table
table = [[ 1, -1, 0, -1, -1, -1],
[-1, -1, 2, -1, -1, -1]]
rules = [[(Rule,N_F)],
[(Term,T_LPAR), (Rule,N_S), (Term,T_PLUS), (Rule,N_F), (Term,T_RPAR)],
[(Term,T_A)]]
stack = [(Term,T_END), (Rule,N_S)]
def lexicalAnalysis(inputstring):
print('Lexical analysis')
tokens = []
#cdict = {'+': T_PLUS, '(': T_LPAR, ')': T_RPAR, 'a': T_A}
#for c in inputstring:
tokens.append(cdict.get(c, T_INVALID))
# in the meantime it has been changed on wikipedia to simple mapping above,
# but the original if-elif-elif-else could be indented to make further distinction
# for multi-character terminals like between '-' and '-&' .
for c in inputstring:
== '+': tokens.append(T_PLUS)
elif c == '(': tokens.append(T_LPAR)
elif c == ')': tokens.append(T_RPAR)
elif c == 'a': tokens.append(T_A)
else: tokens.append(T_INVALID)
tokens.append(T_END)
print(tokens)
return tokens
def syntacticAnalysis(tokens):
print('Syntactic analysis')
position = 0
while len(stack) & 0:
(stype, svalue) = stack.pop()
token = tokens[position]
if stype == Term:
if svalue == token:
position += 1
print('pop', svalue)
if token == T_END:
print('input accepted')
print('bad term on input:', token)
elif stype == Rule:
print('svalue', svalue, 'token', token)
rule = table[svalue][token]
print('rule', rule)
for r in reversed(rules[rule]):
stack.append(r)
print('stack', stack)
inputstring = '(a+a)'
syntacticAnalysis(lexicalAnalysis(inputstring))
As can be seen from the example, the parser performs three types of steps depending on whether the top of the stack is a nonterminal, a terminal or the special symbol $:
If the top is a nonterminal then the parser looks up in the parsing table on the basis of this nonterminal and the symbol on the input stream, which rule of the grammar it should use to replace nonterminal on the stack. The number of the rule is written to the output stream. If the parsing table indicates that there is no such rule then the parser reports an error and stops.
If the top is a terminal then the parser compares it to the symbol on the input stream and if they are equal they are both removed. If they are not equal the parser reports an error and stops.
If the top is $ and on the input stream there is also a $ then the parser reports that it has successfully parsed the input, otherwise it reports an error. In both cases the parser will stop.
These steps are repeated until the parser stops, and then it will have either completely parsed the input and written a
to the output stream or it will have reported an error.
In order to fill the parsing table, we have to establish what grammar rule the parser should choose if it sees a nonterminal A on the top of its stack and a symbol a on its input stream. It is easy to see that such a rule should be of the form A → w and that the language corresponding to w should have at least one string starting with a. For this purpose we define the First-set of w, written here as Fi(w), as the set of terminals that can be found at the start of some string in w, plus ε if the empty string also belongs to w. Given a grammar with the rules A1 → w1, ..., An → wn, we can compute the Fi(wi) and Fi(Ai) for every rule as follows:
initialize every Fi(Ai) with the empty set
add Fi(wi) to Fi(wi) for every rule Ai → wi, where Fi is defined as follows:
Fi(a w' ) = { a } for every terminal a
Fi(A w' ) = Fi(A) for every nonterminal A with ε not in Fi(A)
Fi(A w' ) = Fi(A) \ { ε } ∪ Fi(w' ) for every nonterminal A with ε in Fi(A)
Fi(ε) = { ε }
add Fi(wi) to Fi(Ai) for every rule Ai → wi
do steps 2 and 3 until all Fi sets stay the same.
Unfortunately, the First-sets are not sufficient to compute the parsing table. This is because a right-hand side w of a rule might ultimately be rewritten to the empty string. So the parser should also use the rule A → w if ε is in Fi(w) and it sees on the input stream a symbol that could follow A. Therefore, we also need the Follow-set of A, written as Fo(A) here, which is defined as the set of terminals a such that there is a string of symbols αAaβ that can be derived from the start symbol. We use $ as a special terminal indicating end of input stream and S as start symbol.
Computing the Follow-sets for the nonterminals in a grammar can be done as follows:
initialize Fo(S) with { $ } and every other Fo(Ai) with the empty set
if there is a rule of the form Aj → wAiw' , then
if the terminal a is in Fi(w' ), then add a to Fo(Ai)
if ε is in Fi(w' ), then add Fo(Aj) to Fo(Ai)
if w' has length 0, then add Fo(Aj) to Fo(Ai)
repeat step 2 until all Fo sets stay the same.
Now we can define exactly which rules will be contained where in the parsing table. If T[A, a] denotes the entry in the table for nonterminal A and terminal a, then
T[A,a] contains the rule A → w if and only if
a is in Fi(w) or
ε is in Fi(w) and a is in Fo(A).
If the table contains at most one rule in every one of its cells, then the parser will always know which rule it has to use and can therefore parse strings without backtracking. It is in precisely this case that the grammar is called an LL(1) grammar.
Until the mid-1990s, it was widely believed that LL(k) parsing (for k & 1) was impractical[], since the parser table would have
size in k in the worst case. This perception changed gradually after the release of the
around 1992, when it was demonstrated that many
can be parsed efficiently by an LL(k) parser without triggering the worst-case behavior of the parser. Moreover, in certain cases LL parsing is feasible even with unlimited lookahead. By contrast, traditional parser generators like
parser tables to construct a restricted
with a fixed one-token lookahead.
As described in the introduction, LL(1) parsers recognize languages that have LL(1) grammars, which are a special case of context-free grammars (CFGs); LL(1) parsers cannot recognize all context-free languages. The LL(1) languages are a proper subset of the LR(1) languages which in turn are a proper subset of all context-free languages. In order for a CFG to be an LL(1) grammar, certain conflicts must not arise, which we describe in this section.
Let A be a non-terminal. FIRST(A) is (defined to be) the set of terminals that can appear in the first position of any string derived from A. FOLLOW(A) is the union over FIRST(B) where B is any non-terminal that immediately follows A in the right hand side of a .
There are 2 main types of LL(1) conflicts:
The FIRST sets of two different grammar rules for the same non-terminal intersect. An example of an LL(1) FIRST/FIRST conflict:
S -& E | E 'a'
E -& 'b' | ε
FIRST(E) = {'b', ε} and FIRST(E 'a') = {'b', 'a'}, so when the table is drawn, there is conflict under terminal 'b' of production rule S.
will cause a FIRST/FIRST conflict with all alternatives.
E -& E '+' term | alt1 | alt2
The FIRST and FOLLOW set of a grammar rule overlap. With an
(ε) in the FIRST set it is unknown which alternative to select. An example of an LL(1) conflict:
S -& A 'a' 'b'
A -& 'a' | ε
The FIRST set of A now is {'a', ε} and the FOLLOW set {'a'}.
A common left-factor is "factored out".
A -& X | X Y Z
B -& Y Z | ε
Can be applied when two alternatives start with the same symbol like a FIRST/FIRST conflict.
Another example (more complex) using above FIRST/FIRST conflict example:
S -& E | E 'a'
E -& 'b' | ε
becomes (merging into a single non-terminal)
S -& 'b' | ε | 'b' 'a' | 'a'
then through left-factoring, becomes
S -& 'b' E | E
E -& 'a' | ε
Substituting a rule into another rule to remove indirect or FIRST/FOLLOW conflicts. Note that this may cause a FIRST/FIRST conflict.
For a general method, see . A simple example for left recursion removal: The following production rule has left recursion on E
E -& E '+' T
This rule is nothing but list of Ts separated by '+'. In a regular expression form T ('+' T)*. So the rule could be rewritten as
Z -& '+' T Z
Now there is no left recursion and no conflicts on either of the rules.
However, not all CFGs have an equivalent LL(k)-grammar, e.g.:
S -& A | B
A -& 'a' A 'b' | ε
B -& 'a' B 'b' 'b' | ε
It can be shown that there does not exist any LL(k)-grammar accepting the language generated by this grammar.
Rosenkrantz, D. J.; Stearns, R. E. (1970).
(PDF). Information and Control. 17: 226–256. :.
Dick G Ceriel J.H. Jacobs (29 October 2007). . Springer. pp. 585–.  .
Pat Terry. . Pearson Education. pp. 159–164.
Modern Compiler Design, Grune, Bal, Jacobs and Langendoen
This simulator is used to generate parsing tables LL(1) and to resolve the exercises of the book.
: Hidden categories:g|onll是什么手机_百度知道
g|onll是什么手机
g|onll是什么手机
我有更好的答案
性能天知道!虚假广告牛的很?数据参数多为刷的假数值该手机实际是杂牌子!通俗讲就是山寨货色!软件的兼容性与硬件的匹配差!网络上无资料可查,完全是凭店铺保修。店铺只能是手工维护。能用多久是个人的人品!山寨货都是打一枪换个牌子。挣点钱就跑。质量没保证,无官网,没售后电话和地址
采纳率:84%
来自团队:
为您推荐:
其他类似问题
您可能关注的内容
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。Foucs On LED Lighting
& ONLLA Group Co.,Ltd. is an enterprise that focuses on indoor and outdoor LED lighting products, with independent R & D, Manufacturing, Marketing and after-sale service. It is a member of China Lighting Association, and sponsor of Beijing Chamber of E-Commerce. Registered in Hong Kong, the headquarter of ONLLA Group has several subsidiaries, which are registered respectively in Zhongguancun Science Park of Beijing, Shenzhen Industrial Park, Gu'an Industrial Park in Hebei Province. The production base of the group occupies a total area of 320,000 square meters.&
&International Communication&
International Trade
Global Projects
Our Products:LED Table Lamp、High Bay Light、Street Light&、Flood Light、Bulb、Tube
Supply Products
List price:¥0.00
Price:¥0.00
List price:¥0.00
Price:¥0.00
List price:¥0.00
Price:¥0.00
List price:¥0.00
Price:¥0.00
List price:¥0.00
Price:¥0.00
List price:¥0.00
Price:¥0.00
List price:¥0.00
Price:¥0.00
List price:¥0.00
Price:¥0.00
List price:¥0.00
Price:¥0.00
List price:¥0.00
Price:¥0.00
NEWS CENTER
Copyright (C) :ONLLA &GroupAll Rights Reserved
ONLLA Technology Co., Ltd.REIT Technology Co., Ltd.Addr:F11 Huibing Build Chaoyang,&BeijingTel : &+86-10-WhatsApp: +86 186 Email:
My Account}

我要回帖

更多关于 rn scorview onscorll 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信