12.3E-15, 12.3E5 - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

12.3E-15, 12.3E5

Description:

... Microsoft.VisualBasic.Left(Alltext, 1) Select Case ScanMode Case 0 CH2 = Microsoft.VisualBasic.Left (Alltext, 2) If ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 18
Provided by: shir122
Category:

less

Transcript and Presenter's Notes

Title: 12.3E-15, 12.3E5


1
3.2 ??????????(1)?????
???????? 1?(????
??/???/ ??/?????
??????
12.3,E,-15, 12.3,E5,,, gt,lt,, while,
if,???,abcdefg
  • 1????
  • (???????)

?????? ????
????
??? ????? ????
????? ???? ????
12.3E-15, 12.3E5 ,,, gt, , while,
if,???, abcdefg
????
2
(2)1????(???????)
  • VB??????1????
  • ?1??1?????
  • ?1??????????()????
  • ???????????????????(_)????????
  • ???????????????()

3
1?????????
  • ?????

???
?? ???
?????
???()
???()
?????
???
???
???()
????????
???? _
???????(????)
?????
???
?????
???????(???)
????
???
???
??????
??
????C???1??????????????? ?8??????????? ?\n,\?????
??????????
4
??(1)
  • Private Alltext As String
  • Private ScanMode As Short
  • Private Function scanComment() As String
  • Dim CH1, CH2 As String Dim LN As
    Integer
  • CH1 Microsoft.VisualBasic.Left(Alltext,
    1)
  • Select Case ScanMode
  • Case 0
  • CH2 Microsoft.VisualBasic.Left(A
    lltext, 2)
  • If CH1 " " Or CH1 " " Or CH1
    vbTab Then
  • LN Microsoft.VisualBasic.Len
    (Alltext)
  • Alltext Microsoft.VisualBasi
    c.Right(Alltext, LN - 1)
  • scanComment " "
  • ElseIf CH2 vbCrLf Then
  • LN Microsoft.VisualBasic.Len
    (Alltext)
  • Alltext Microsoft.VisualBasi
    c.Right(Alltext, LN - 2)
  • scanComment " "
  • ElseIf CH2 "//" Then
  • LN Microsoft.VisualBasic.Len
    (Alltext)
  • Alltext Microsoft.VisualBasi
    c.Right(Alltext, LN - 2)

5
??(2)
  • ElseIf CH2 "/" Then
  • LN Microsoft.VisualBasic.Len
    (Alltext)
  • Alltext Microsoft.VisualBasi
    c.Right(Alltext, LN - 2)
  • Do While Alltext ltgt ""
  • CH2 Microsoft.VisualBasi
    c.Left(Alltext, 2)
  • If CH2 "/" Then
  • LN
    Microsoft.VisualBasic.Len(Alltext)
  • Alltext
    Microsoft.VisualBasic.Right(Alltext, LN - 2)
  • Exit Do
  • End If
  • LN Microsoft.VisualBasic
    .Len(Alltext)
  • Alltext
    Microsoft.VisualBasic.Right(Alltext, LN - 1)
  • Loop
  • scanComment " "
  • Else
  • scanComment CH1
  • LN Microsoft.VisualBasic.Len
    (Alltext)
  • Alltext Microsoft.VisualBasi
    c.Right(Alltext, LN - 1)
  • If CH1 """" Then

6
??(3)
  • If CH1 """" Then
  • ScanMode 0
  • ElseIf CH1 "\" Then
  • ScanMode 3
  • End If
  • Case 2
  • scanComment CH1
  • LN Microsoft.VisualBasic.Len(All
    text)
  • Alltext Microsoft.VisualBasic.Ri
    ght(Alltext, LN - 1)
  • ScanMode 0
  • Case 3
  • scanComment CH1
  • LN Microsoft.VisualBasic.Len(All
    text)
  • Alltext Microsoft.VisualBasic.Ri
    ght(Alltext, LN - 1)
  • ScanMode 1
  • End Select
  • End Function
  • Private Sub Button2_Click(ByVal sender As
    System.Object, ByVal e As System.EventArgs)
    Handles Button2.Click
  • Dim R, Str As String

7
(3)??????
  • ?????

?????? ????????
???
?? ???
??? ??
???()
???()
??? ??
???
???
????
(1??)
???()
????????
??
??
???
?? ???
???
??
????????
??? ???
???
????
?????????? ????????.?????? .?????????????
??
???
??? ???
?????
??
????C??????????????????????? ?????????????,
?????????????, \n, \????????????
8
C?????????(??1)
  • Private Function setWordData(ByVal tp As String,
    ByVal st As String) As WordData
  • setWordData.Type tp
  • setWordData.Str st
  • End Function
  • Private Function setString()
  • Dim Str, R As String
  • Str """" R scanComment()
  • Do While R ltgt """"
  • If R "\" Then
  • Str Str R R scanComment()
  • If R "" Then
  • MsgBox("????????????????????")
  • R """"
  • Exit Do
  • End If
  • End If
  • Str Str R R scanComment()
  • Loop
  • setString Str R

9
C?????????(??2)
  • Private Function setChar()
  • Dim Str, R As String
  • Str "'" R scanComment()
  • Do While R ltgt "'"
  • If R "\" Then
  • Str Str R R scanComment()
  • If R "" Then
  • MsgBox("????????????????????")
  • R "'"
  • Exit Do
  • End If
  • End If
  • Str Str R R scanComment()
  • Loop
  • setChar Str R
  • End Function

10
C?????????(??3)
  • Private Function setNumber(ByVal RR As String)
  • Dim Str, R As String R RR
  • If R ltgt "." Then
  • Str RR R scanComment()
  • Do While Asc(R) gt Asc("0") And
    Asc(R) lt Asc("9")
  • Str Str R R scanComment()
  • Loop
  • If R ltgt "." Then
  • Alltext R Alltext setNumber
    Str
  • Exit Function
  • End If
  • End If
  • Str Str R R scanComment()
  • Do While Asc(R) gt Asc("0") And Asc(R) lt
    Asc("9")
  • Str Str R R scanComment()
  • Loop
  • Alltext R Alltext
  • setNumber Str
  • End Function

11
C?????????(??4)
  • Private Function setName(ByVal RR As String)
  • Dim Str, R As String
  • R RR Str RR R scanComment()
  • Do While (Asc(R) gt Asc("A") And Asc(R)
    lt Asc("Z")) Or _
  • (Asc(R) gt Asc("a") And Asc(R)
    lt Asc("z")) Or _
  • (Asc(R) gt Asc("0") And Asc(R)
    lt Asc("9")) Or R "_"
  • Str Str R
  • R scanComment()
  • Loop
  • Alltext R Alltext
  • setName Str
  • End Function

12
C?????????(??4)
  • Private Function LA0() As WordData
  • Dim R, Str As String Str "" ScanMode
    0 R scanComment()
  • Do While Alltext ltgt "" And (R " " Or R
    "")
  • R scanComment()
  • Loop
  • If (R " " Or R "") And Alltext ""
    Then
  • LA0.Type "EOF LA0.Str ""
  • ElseIf R """" Then
  • LA0.Type "String LA0.Str
    setString()
  • ElseIf R "'" Then
  • LA0.Type "Char LA0.Str
    setChar()
  • ElseIf R "\" Then
  • LA0.Type "Code LA0.Str R
    scanComment()
  • ElseIf R "." Then
  • LA0.Type "Number LA0.Str
    setNumber(R)
  • If LA0.Str "." Then LA0.Type "Delimiter"
  • ElseIf Asc(R) gt Asc("0") And Asc(R) lt
    Asc("9") Then
  • LA0.Type "Number LA0.Str
    setNumber(R)
  • ElseIf (Asc(R) gt Asc("A") And Asc(R) lt
    Asc("Z")) Or _

13
C?????????(??5)
  • Private Sub Button3_Click(ByVal sender As
    System.Object, ByVal e As System.EventArgs)
    Handles Button3.Click
  • Dim S As WordData
  • Alltext TextBox1.Text
  • TextBox2.Text ""
  • Do While Alltext ltgt ""
  • S LA0()
  • TextBox2.Text TextBox2.Text
    vbCrLf S.Type " Value""" S.Str """"
  • Loop
  • End Sub
  • End Class

14
(4)?????????????
  • ????????????123.5E-23???34.E5?????
  • ???123.5?? ???E????????-?????23?
  • ???34.?? ???E5?
  • ?16???0X0FEC?????
  • ???0?? ???X0FEC?
  • ?8???0276?(???0????)
  • ?????????????(, , ??)
  • ?2????????????????????(BASIC???)
  • select case, end if, do while, loop until,

?????????????
15
C??????(??1)
  • private bool E_exp(string str) // Elt???gt?????
  • if(str.Lengthlt2) return false
  • if(str0!'E' str0!'e') return false
  • for(int i1iltstr.Lengthi)
    if(????(??,stri)lt0) return false
  • return true
  • private void set_TokenX(string type, string str)
    // ????????
  • tokenXnumTokenX.typetype
  • tokenXnumTokenX.strstr
  • numTokenX
  • private void combineDelimiter(string str1, string
    str2) // ????????
  • set_TokenX("Delimiter",str1str2)

16
C??????(??2)
  • private void LA1()
  • numTokenX0 WordData token1,token2,token3,toke
    n4
  • token1LA0()token2LA0()token3LA0()token4LA
    0() // ???
  • while(token1.type!"End")
  • if( token1.type"Number"
    token2.type"Name" token2.str"E"
  • token3.type"Delimiter" (token3.str""
    token3.str"-")
  • token4.type"Number")
  • set_TokenX("Number",token1.strtoken2.strto
    ken3.strtoken4.str)
  • token1LA0()token2LA0()token3LA0()toke
    n4LA0()
  • else if( token1.type"Number"
    token2.type"Name" E_exp(token2.str))
  • set_TokenX("Number",token1.strtoken2.str)
  • token1token3token2token4token3LA0()tok
    en4LA0()
  • else if(token1.type"Delimiter"
    token1.str"gt"
  • token2.type"Delimiter"
    token2.str"" )
  • combineDelimiter(token1.str,token2.str)
  • token1token3token2token4token3LA0()tok
    en4LA0()

17
(5)1?????????????????
  • ????????????????
  • (??????????????????)
  • FORTRAN, BASIC, COBOL

SA
LA1
1????
1?????
LA0
????????????????? (begin-end,)???????
ALGOL,PL/I, C, C,JAVA, C
SA
LA1
LA0
1?????
Write a Comment
User Comments (0)
About PowerShow.com