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?

Entry

TSE: Parser: Syntax: Structure: While: Occurrence: *: How create parser for 0 or more occurrences?

Oct 20th, 2003 17:21
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 25 September 2003 - 01:26 am ------------------

TSE: Parser: Syntax: Structure: While: Occurrence: *: How create 
parser for 0 or more occurrences?

---

How to possibly parse zero or more occurrences of some object (e.g. a
string, a paragraph, ...):

---
---

e.g. Suppose you define a block of text as a collection
of zero or more paragraphs.

---
---

In words:

a block of text is a collection of zero or more paragraphs.

---

In Backus Naur Form:

[block] = [paragraph]*

---

In Backus Naur Form diagram:

               +----------<--------+
               |                   |
 'block' = -->-+->--[paragraph]-->-+->--
               |                   |
               +---------->--------+

---

In pseudo code:

while 'condition'
 get 'paragraph'
endwhile

---
---

In pseudo code: in general:

while 'condition'
 get 'value'
endwhile

---
---

As regular expression: non-greedy:

{paragraph}*

---
---

As regular expression: non-greedy: in general:

{value}*

---
---

As regular expression: greedy:

{paragraph}@

---
---

As regular expression: greedy: in general:

{value}@

---
---

Note: So you use a while loop, because of this corresponds also to a
loop which might be executed not at all (=0 times) or more.

---
---

Internet: see also:

TSE: Parser: Syntax: Structure: Serial: Occurrence: &: And: How create 
parser for serial occurrence?
http://www.faqts.com/knowledge_base/view.phtml/aid/24710/fid/1236

---

TSE: Parser: Syntax: Structure: If: Occurrence: ?: How to create a 
parser for 0 or 1 occurrences?
http://www.faqts.com/knowledge_base/view.phtml/aid/24708/fid/1236

---

TSE: Parser:Syntax:Structure:Parallel:Occurrence: |: How create parser 
for 1 or more parallel cases?
http://www.faqts.com/knowledge_base/view.phtml/aid/24705/fid/1236

---

TSE: Parser: Syntax:Structure:Repeat: Occurrence: +: How to create 
parser for 1 or more occurrences?
http://www.faqts.com/knowledge_base/view.phtml/aid/24703/fid/1236

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