The remarkable similarities between Flex/Lex and XSLT

Roger L Costello <costello@mitre.org>
Fri, 24 Jun 2022 10:57:51 +0000

          From comp.compilers

Related articles
The remarkable similarities between Flex/Lex and XSLT costello@mitre.org (Roger L Costello) (2022-06-24)
Re: The remarkable similarities between Flex/Lex and XSLT gah4@u.washington.edu (gah4) (2022-06-24)
Compiler-compiler-compiler christopher.f.clark@compiler-resources.com (Christopher F Clark) (2022-06-25)
Re: The remarkable similarities between Flex/Lex and XSLT matt.timmermans@gmail.com (matt.ti...@gmail.com) (2022-06-25)
| List of all articles for this month |

From: Roger L Costello <costello@mitre.org>
Newsgroups: comp.compilers
Date: Fri, 24 Jun 2022 10:57:51 +0000
Organization: Compilers Central
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="99596"; mail-complaints-to="abuse@iecc.com"
Keywords: lex, history, comment
Posted-Date: 24 Jun 2022 09:00:41 EDT
Content-Language: en-US

Hi Folks,


XSLT is a language for processing XML documents.


There are remarkable similarities between Flex/Lex and XSLT. Lex was created
47 years ago, long before XSLT. One wonders if some members of the XSLT 1.0
Working Group were Lex users and were influenced by its concepts?


Here are some of the similarities between Flex/Lex and XSLT:


Both are pattern-matching languages, i.e.,


pattern action
pattern action
pattern action


Both allow you to create subsets:


The XSLT "mode" allows the program to effectively be broken into a set of
mini XSLT programs
The Flex/Lex "start condition" allows the lexer to effectively be broken into
a set of mini lexers


Both have a default rule that is executed when no other rule matches


There are some differences, of course:


XSLT is primarily for processing XML but it can process plain text, whereas
Flex/Lex is primarily for processing plain text (esp. source code) but it can
process XML


XSLT uses XPath as its pattern-matching language, whereas Flex/Lex uses
regular expressions as its pattern-matching language


Pretty interesting, I think!


/Roger
[I would be surprised if the XSLT authors hadn't seen lex but Wikipedia suggests
it was more influenxed by awk, which also has pattern action lines. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.