上下文无关语法 [英] Context free grammar

查看:66
本文介绍了上下文无关语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种语言需要写上下文无关语法 为此。如果有
提案发送给我 谢谢。












DO


   
I,j,a:整数


   
x,y:real


   
mx [50]:real


END


DO


 
I:= 1


< span style ="font-family:Nazli">  
j:= 1


< span style ="font-family:Nazli">  
打印'输入我'


 
INPUT I


 
如果I = 1


< span style ="font-family:Nazli">      
j:= j +1


     
mx [0]:= 5


 
ELIF    I = 2


      
j:= j + 4;


     
mx [0]:= 12


  
ELSE


     
myF1(j,i)


     
mx [0]   := 34


  
结束


  
在我< 45


的时候做什么

        
a:= a + 2


        
DO J:= 1到10 BY 2


            
DO Z:= 1到20


<跨度风格=" font-family:纳兹勒 "> <跨度风格="">&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
k:= j + 2


<跨度风格= "">&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
如果K = 30


< span style ="font-family:Nazli">                  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
BREAK


&span style ="">                   ;&NBSP;&NBSP;&NBSP;
ELIF K = 40


< span style ="font-family:Nazli">                  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
BREAK 2


&span style ="">                  &NBSP;&NBSP;&NBSP;&NBSP;
ELIF K = 50


< span style ="font-family:Nazli">                  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
BREAK 3


&span style ="">                  &NBSP;&NBSP;&NBSP;&NBSP;
结束


             
结束


        
结束


  
结束


结束  



函数myF1(m:integer,n:integer)


REM这是评论


do


 
st:string


  
x:real


rem *******


  
I:整数


end


do


 
st:=“ hello“


 
print st,m,'hello2'  rem commnet


 
输入x


 
如果x = 12


< span style ="font-family:Nazli">    
st = st +'yes'


 
结束


 
执行  i< m


    
x:= i * 2 -12


 
结束


 
x:= nextF(x)


 
print x


结束


函数nextF(x: 
real)  真实



结束



 
返回x * x


< span style ="font-family:Nazli"> end


< span style ="font-family:Nazli"> *上下字之间没有差异


 


判别-------------------


 



 



 


优先级
运营商------------- ------


()[]


+ -


^   
From Right to Left        
 


*  
/


+   
-


=    
< &NBSP;&NBSP;&NBSP; < = <跨度风格= "">&NBSP;&NBSP;&NBSP;&NBSP;
>的&NBSP;&NBSP;&NBSP ; > =      
<>


< p style ="margin-bottom:.0001pt;行高:正常; text-autospace:none"> not


     
     


  :=





Constance --------------------------------- --------

'  
&NBSP;&NBSP;
'  


  
'    


 
\”   ; 


' 
\'   ;  '





* Key
字(对上下字不敏感)


 


while while


执行 
到[by]  


if    
elif   ; 其他


end


return


function


* expr =必须中断的循环次数


*如果不存在,则打破内部循环


break [expr [



print


输入


rem


integer


real


string


 


 


解决方案

您的问题应该发布到相应的MSDN论坛。 此论坛是关于Microsoft认证的问题。

I have this language that want write context free grammar  for that .if have Proposal send me Thanks.

DO

    I , j , a : integer

    x , y : real

    mx[50] : real

END

DO

  I:=1

  j:=1

  PRINT 'Enter I '

  INPUT I

  IF I = 1

      j:= j +1

      mx[0] := 5

  ELIF   I=2

       j:=j+4;

      mx[0]:=12

   ELSE

      myF1(j,i)

      mx[0]  := 34

   END

   DO WHILE I <45

         a :=a+2

         DO J :=1 TO 10 BY 2

             DO Z := 1 TO 20

                      k:=j+2

                      IF K = 30

                            BREAK

                      ELIF K=40

                            BREAK 2

                      ELIF K=50

                            BREAK 3

                      END

              end

         end

   end

end 

Function myF1( m: integer, n: integer )

REM this is comment

do

  st: string

   x: real

rem *******

   I: integer

end

do

  st := “hello “

  print st , m , 'hello2 '  rem commnet

  input x

  if x =12

    st = st + 'yes'

  end

  do while  i<m

     x :=i *2 -12

  end

  x := nextF(x)

  print x

end

function nextF(x :  real)  real

do

end

do

  return x*x

end

*Not Different Between Upper And Lower Word

 

Discriminant-------------------

: 

,

 

 

Priority of operators-------------------

() []

+ -

^   From Right To Left      

*  /

+   -

=    <    <=     >    >=      <>

not

and      or     

 :=


Constance-----------------------------------------

'      '  

   '   

  \”  

'  \'    '


*Key words (Not sensitive to upper and lower word)

 

do while

do  to [by] 

if    elif  else

end

return

function

*expr=number of loop that must break

*if not exist break inner loop

break [expr[

print

input

rem

integer

real

string

 

 

解决方案

Your question should be posted to the appropriate MSDN forum.  This forum is for questions relating to Microsoft Certifications.


这篇关于上下文无关语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆