faqts : Computers : Programming : Languages : Tse : Parser

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

0 of 2 people (0%) answered Yes
Recently 0 of 2 people (0%) answered Yes

Entry

TSE: Parser: Syntax: Analysis: Language: Assembler: How to parse an assembler function? [find]

Jun 20th, 2004 14:06
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 20 Juny 2004 - 06:59 pm -----------------------

TSE: Parser: Syntax: Analysis: Language: Assembler: How to parse an 
assembler function? [find]

---

ASSEMBLER: function: find: regular expression: string


 string asm_fun[] = "[a-zA-Z0-9] +{proc}"


---

ASSEMBLER: function: regular expression: in words

An assembler function

 1. starts with 1 alphanumeric character (or a to z, or A to Z, or 0 
to 9),

 2. followed by 1 or more spaces,

 3. followed by 1 word 'proc'

---

ASSEMBLER: function: example:

 a proc

 b proc

 A proc

 B proc

 0 proc

 9 proc

---

ASSEMBLER: function: BNF: description

function = (alphanumeric_character) (space)+ 'proc'

alphanumeric_character = lower_case_alphanumeric_character | 
upper_case_alphanumeric_character | digit

lower_case_alphanumeric_character = a..z

upper_case_alphanumeric_character = A..Z

digit = 0..9

---

ASSEMBLER: function: BNF: syntax diagram:


       +-->--[a..z]-->--+     +------<------+
       |                |     |             |
  -->--+-->--[A..Z]-->--+-->--+-->--[ ]-->--+-->--(proc)-->--
       |                |
       +-->--[0..9]-->--+

---


ASSEMBLER: function: syntax analysis:

PROC PROCLanguageCheckFunctionComputerAssemblerSyntaxAnalysis()
 //
 // ---
 //
 // To run:
 //
 //  1. Compile this macro
 //
 //  2. Put the cursor on the first character of the function
 //
 //  3. Press <F12>
 //
 //  4. If the cursor then moves to the end of the function name,
 //     it is a valid name according to the given syntax
 //
 // ---
 //
 // Example of assembler functions:
 //
 // a       proc
 //
 //
 // b   proc
 //
 // C   proc
 //
 // 0 proc
 //
 // ---
 //
 // An assembler function
 //
 // 1. starts with 1 alphanumeric character (or a to z, or A to Z, or 
0 to 9),
 //
 IF NOT ( Chr( CurrChar() ) IN 'a'..'z', 'A'..'Z', '0'..'9' )
  Warn( 'assembler: function: does not start with 1 character a-z, A-
Z, 0-9' )
  RETURN()
 ENDIF
 //
 // goto the next character
 //
 NextChar()
 //
 // 2. followed by 1 or more spaces,
 //
 IF NOT ( Chr( CurrChar() ) IN ' ' )
  Warn( 'assembler: function: at least 1 space expected after the 
first character' )
  RETURN()
 ENDIF
 //
 // move past any spaces
 WHILE ( Chr( CurrChar() ) IN ' ' )
  NextChar()
 ENDWHILE
 //
 // goto the next character
 //
 NextChar()
 //
 // 3. followed by 1 word 'proc'
 //
 IF NOT( GetWord() == 'proc' )
  Warn( 'assembler: function: word "proc" expected after the space' )
  RETURN()
 ENDIF
 //
 // goto the end of the current word
 //
 EndWord()
 //
END

PROC Main()
 PROCLanguageCheckFunctionComputerAssemblerSyntaxAnalysis()
END

<F12> Main()

---
---

Internet: see also:

---

TSE: Parser: Syntax: Analysis: Language: Function: Can you give 
overview of how to parse functions?
http://www.faqts.com/knowledge_base/view.phtml/aid/30300/fid/1236

----------------------------------------------------------------------