Related articles |
---|
Is it the job of a parser to validate the input data? costello@mitre.org (Roger L Costello) (2021-08-11) |
Is it the job of a parser to validate the input data? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2021-08-12) |
Re: Is it the job of a parser to validate the input data? gneuner2@comcast.net (George Neuner) (2021-08-12) |
Re: Is it the job of a parser to validate the input data? luser.droog@gmail.com (luser droog) (2021-09-03) |
From: | Roger L Costello <costello@mitre.org> |
Newsgroups: | comp.compilers |
Date: | Wed, 11 Aug 2021 22:24:49 +0000 |
Organization: | Compilers Central |
Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="77587"; mail-complaints-to="abuse@iecc.com" |
Keywords: | parse, question |
Posted-Date: | 11 Aug 2021 22:25:48 EDT |
Thread-Topic: | Is it the job of a parser to validate the input data? |
Thread-Index: | AdeO/yfqE84hoTMsQgegIuM0ZDEzoQ== |
Accept-Language: | en-US |
Content-Language: | en-US |
Hello Compiler Experts!
There are many data formats which contain things like this:
A number, N
N occurrences of something
For example, 3 followed by the names of three students:
3
John Doe
Sally Smith
Judy Jones
I have a question about parsing such data. Is it the job of a parser to ensure
that the number of student names matches the number? Or, is it the job of the
parser to merely tokenize whatever is in the input and then create an abstract
syntax tree containing the tokens?
I imagine you will tell me, "it depends". But what is typically the case?
/Roger
[You can indeed do it either way. I prefer to do the counting in the AST creation
so it can produce errors like "too few names" rather than a generic "syntax error",
although putting it all in the parser makes it more likely that the language you
parse is actually the language you think you're parsing. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.