简体   繁体   English

这是语法LL(1)

[英]Is this grammar LL(1)

I have been asked to convert: 我被要求转换:

S → Sa | bSb | bc 

to LL(1) so far I have: 到目前为止,我有LL(1):

S → bY
Y → SbF | cF
F → aF | ε

Is this LL(1)? 这是LL(1)吗? If not would this be LL(1): 如果不是,则为LL(1):

S → bY
Y → bYbF | cF
F → aF | ε

if neither of these would somebody please give me the correct answer and why thanks in advance! 如果这些都不能有人给我正确的答案,为什么要提前感谢!

This is what I would do: 这就是我要做的:

S → Sa | bSb | bc 
  1. Remove left recursion: 删除左递归:

     F -> aF | EPSILON``` 
  2. Now left factor: 现在剩下的因素:

     F -> aF | EPSILON X -> SbF | cF``` 
  3. Check the First and Follows: 首先检查并遵循:

     S: b X: b, c F: a, EPSILON``` ```Follows(): S: $, b X: $, b F: $, b``` Everything checks out so it is LL(1) parsable. 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM