<feed xmlns='http://www.w3.org/2005/Atom'>
<title>plan9port/src/cmd/rc/lex.c, branch patch</title>
<subtitle>Plan 9 from User Space (with patches)</subtitle>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/'/>
<entry>
<title>rc: clean up parser levels, disallow free carats on lists</title>
<updated>2020-05-05T12:30:14+00:00</updated>
<author>
<name>Russ Cox</name>
<email>rsc@swtch.com</email>
</author>
<published>2020-05-05T12:29:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=601e07b63653d0fed91594ebba261b733d017653'/>
<id>601e07b63653d0fed91594ebba261b733d017653</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>rc: move free carat handling into parser</title>
<updated>2020-05-05T03:41:15+00:00</updated>
<author>
<name>Russ Cox</name>
<email>rsc@swtch.com</email>
</author>
<published>2020-05-05T03:20:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=7d6a248f2c68d70f58387afc69e73e695c3d940c'/>
<id>7d6a248f2c68d70f58387afc69e73e695c3d940c</id>
<content type='text'>
This fixes at least one shell script (printfont) that expected

	'x'`{y}'z'

to mean

	'x'^`{y}^'z'

as it now does. Before it meant:

	'x'^`{y} 'z'

One surprise is that adjacent lists get a free carat:

	(x y z)(1 2 3)

is

	(x1 y2 z3)

This doesn't affect any rc script in Plan 9 or plan9port.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes at least one shell script (printfont) that expected

	'x'`{y}'z'

to mean

	'x'^`{y}^'z'

as it now does. Before it meant:

	'x'^`{y} 'z'

One surprise is that adjacent lists get a free carat:

	(x y z)(1 2 3)

is

	(x1 y2 z3)

This doesn't affect any rc script in Plan 9 or plan9port.
</pre>
</div>
</content>
</entry>
<entry>
<title>rc: move newline handling into parser</title>
<updated>2020-05-05T03:41:15+00:00</updated>
<author>
<name>Russ Cox</name>
<email>rsc@swtch.com</email>
</author>
<published>2020-05-05T02:52:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=3caf5c238a886d06b438ec6d42f2609b8625463f'/>
<id>3caf5c238a886d06b438ec6d42f2609b8625463f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>rc: add recursive descent parser</title>
<updated>2020-05-05T03:41:15+00:00</updated>
<author>
<name>Russ Cox</name>
<email>rsc@swtch.com</email>
</author>
<published>2020-05-04T22:34:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=47d4646eebac34c0b94951cfcf1b81ed2ca513e1'/>
<id>47d4646eebac34c0b94951cfcf1b81ed2ca513e1</id>
<content type='text'>
The old yacc-based parser is available with the -Y flag,
which will probably be removed at some point.

The new -D flag dumps a parse tree of the input,
without executing it. This allows comparing the output
of rc -D and rc -DY on different scripts to see that the
two parsers behave the same.

The rc paper ends by saying:

	It is remarkable that in the four most recent editions of the UNIX
	system programmer’s manual the Bourne shell grammar described in the
	manual page does not admit the command who|wc. This is surely an
	oversight, but it suggests something darker: nobody really knows what
	the Bourne shell’s grammar is. Even examination of the source code is
	little help. The parser is implemented by recursive descent, but the
	routines corresponding to the syntactic categories all have a flag
	argument that subtly changes their operation depending on the context.
	Rc’s parser is implemented using yacc, so I can say precisely what the
	grammar is.

The new recursive descent parser here has no such flags.
It is a straightforward translation of the yacc.

The new parser will make it easier to handle free carats
in more generality as well as potentially allow the use of
unquoted = as a word character.

Going through this exercise has highlighted a few
dark corners here as well. For example, I was surprised to
find that

	x &gt;f | y
	&gt;f x | y

are different commands (the latter redirects y's output).

It is similarly surprising that

	a=b x | y

sets a during the execution of y.

It is also a bit counter-intuitive

	x | y | z
	x | if(c) y | z

are not both 3-phase pipelines.

These are certainly not things we should change, but they
are not entirely obvious from the man page description,
undercutting the quoted claim a bit.

On the other hand, who | wc is clearly accepted by the grammar
in the manual page, and the new parser still handles that test case.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The old yacc-based parser is available with the -Y flag,
which will probably be removed at some point.

The new -D flag dumps a parse tree of the input,
without executing it. This allows comparing the output
of rc -D and rc -DY on different scripts to see that the
two parsers behave the same.

The rc paper ends by saying:

	It is remarkable that in the four most recent editions of the UNIX
	system programmer’s manual the Bourne shell grammar described in the
	manual page does not admit the command who|wc. This is surely an
	oversight, but it suggests something darker: nobody really knows what
	the Bourne shell’s grammar is. Even examination of the source code is
	little help. The parser is implemented by recursive descent, but the
	routines corresponding to the syntactic categories all have a flag
	argument that subtly changes their operation depending on the context.
	Rc’s parser is implemented using yacc, so I can say precisely what the
	grammar is.

The new recursive descent parser here has no such flags.
It is a straightforward translation of the yacc.

The new parser will make it easier to handle free carats
in more generality as well as potentially allow the use of
unquoted = as a word character.

Going through this exercise has highlighted a few
dark corners here as well. For example, I was surprised to
find that

	x &gt;f | y
	&gt;f x | y

are different commands (the latter redirects y's output).

It is similarly surprising that

	a=b x | y

sets a during the execution of y.

It is also a bit counter-intuitive

	x | y | z
	x | if(c) y | z

are not both 3-phase pipelines.

These are certainly not things we should change, but they
are not entirely obvious from the man page description,
undercutting the quoted claim a bit.

On the other hand, who | wc is clearly accepted by the grammar
in the manual page, and the new parser still handles that test case.
</pre>
</div>
</content>
</entry>
<entry>
<title>Trivial changes: whitespace and modes.</title>
<updated>2020-01-10T14:54:30+00:00</updated>
<author>
<name>Dan Cross</name>
<email>cross@gajendra.net</email>
</author>
<published>2020-01-10T14:44:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=fa325e9b42b0bdfb48857d1958d9fb7ceac55151'/>
<id>fa325e9b42b0bdfb48857d1958d9fb7ceac55151</id>
<content type='text'>
Remote whitespace at the ends of lines.
Remove blank lines from the ends of files.
Change modes on source files so that they
are not executable.

Signed-off-by: Dan Cross &lt;cross@gajendra.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remote whitespace at the ends of lines.
Remove blank lines from the ends of files.
Change modes on source files so that they
are not executable.

Signed-off-by: Dan Cross &lt;cross@gajendra.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rc: handle 4-byte utf-8</title>
<updated>2011-01-02T18:44:15+00:00</updated>
<author>
<name>Russ Cox</name>
<email>rsc@swtch.com</email>
</author>
<published>2011-01-02T18:44:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=0786c9647c0232825777d8e1c464bef72fdac738'/>
<id>0786c9647c0232825777d8e1c464bef72fdac738</id>
<content type='text'>
R=rsc
http://codereview.appspot.com/3833043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
R=rsc
http://codereview.appspot.com/3833043
</pre>
</div>
</content>
</entry>
<entry>
<title>sync with plan 9</title>
<updated>2007-03-26T12:02:41+00:00</updated>
<author>
<name>rsc</name>
<email>devnull@localhost</email>
</author>
<published>2007-03-26T12:02:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=c8f538425f4e92e1e438b9bd25cb08e250a93d5b'/>
<id>c8f538425f4e92e1e438b9bd25cb08e250a93d5b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>update lucida</title>
<updated>2006-03-20T02:25:59+00:00</updated>
<author>
<name>rsc</name>
<email>devnull@localhost</email>
</author>
<published>2006-03-20T02:25:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=17157e4aa85baea6c1503e2c95d98ed66a1596f1'/>
<id>17157e4aa85baea6c1503e2c95d98ed66a1596f1</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>correct command-printing bug</title>
<updated>2005-03-18T18:54:54+00:00</updated>
<author>
<name>rsc</name>
<email>devnull@localhost</email>
</author>
<published>2005-03-18T18:54:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=168518a993a67436d00c40f4f9cea68a296a2034'/>
<id>168518a993a67436d00c40f4f9cea68a296a2034</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Plan 9's rc.</title>
<updated>2003-11-23T18:04:08+00:00</updated>
<author>
<name>rsc</name>
<email>devnull@localhost</email>
</author>
<published>2003-11-23T18:04:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rctt.net/plan9port/commit/?id=f08fdedcee12c06e3ce9ac9bec363915978e8289'/>
<id>f08fdedcee12c06e3ce9ac9bec363915978e8289</id>
<content type='text'>
not a clear win over byron's,
but at least it has the right syntax.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
not a clear win over byron's,
but at least it has the right syntax.
</pre>
</div>
</content>
</entry>
</feed>
