Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #3094

The remarkable similarities between Flex/Lex and XSLT

From Roger L Costello <costello@mitre.org>
Newsgroups comp.compilers
Subject The remarkable similarities between Flex/Lex and XSLT
Date 2022-06-24 10:57 +0000
Organization Compilers Central
Message-ID <22-06-073@comp.compilers> (permalink)

Show all headers | View raw


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]

Back to comp.compilers | Previous | NextNext in thread | Find similar


Thread

The remarkable similarities between Flex/Lex and XSLT Roger L Costello <costello@mitre.org> - 2022-06-24 10:57 +0000
  Re: The remarkable similarities between Flex/Lex and XSLT gah4 <gah4@u.washington.edu> - 2022-06-24 06:43 -0700
    Compiler-compiler-compiler Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-06-25 18:32 +0300
  Re: The remarkable similarities between Flex/Lex and XSLT "matt.ti...@gmail.com" <matt.timmermans@gmail.com> - 2022-06-25 09:20 -0700

csiph-web