Selective searching while driving the role of experience in hazard detection and general su

Selective searching while driving the role of experience in hazard detection and general su
Selective searching while driving the role of experience in hazard detection and general su

Ergonomics, 45, 1-15 (2002)

Selective searching while driving: the role of experience in hazard detection and general surveillance

Geoffrey Underwood, David Crundall and Peter Chapman School of Psychology, University of Nottingham

Nottingham NG7 2RD, UK

Keywords: Visual search; Driving; Hazard detection; Skill and experience

Abstract

Novice drivers have been found in previous studies to display a limited search of the immediate environment, relative to experienced drivers, when manoeuvring on a dual-carriageway road. The present study investigated whether this reduction in the variance of search along the horizontal plane was a product of less frequent glancing in the car’s mirrors. Novice and experienced drivers were observed as they made lane changes in relatively unobstructed conditions and when they needed to move into a lane already occupied by traffic. Novice drivers were found to rely more than experienced drivers upon their internal mirror, even when the lane-changing manoeuvre required information about traffic in the lane best reflected in the external, door-mounted mirror. Novices did increase their use of the external mirror in response to driving needs, suggesting that they did have an awareness of the situation that required inter-weaving with traffic in their destination lane. Their reliance upon the internal mirror may be a product of a habit acquired specifically for the driver licensing examination, in which exaggerated inspection of the internal mirror is regarded as desireable.

1.Introduction

In a review of models of driving behaviour, Ranney (1994) highlighted visual search as an aspect of driving that must be central to a complete description of the cognitive abilities necessary for a skilled driver. The identification of salient information, both static and moving objects is critically important at both the strategic level of activity involving navigation and route-choice, and at the tactical level that involves manoeuvring relative to other vehicles and avoiding unexpected hazards. Failure to search the roadway effectively is likely to result in a collision with another vehicle, or at best neglect of route information. In this paper we report a study of the patterns of visual search by drivers of different ability as they negotiate sections of multi-lane roadway that present different levels of difficulty.

Current evidence suggests that newly qualified drivers are particularly vulnerable to driving errors that are associated with inefficient visual search. An analysis of written police reports of road traffic accidents in California reported by Lestina and Miller (1994) found that the single most common contributor to a crash was failure to search the roadway. Drivers were cited as not searching far enough ahead, or of being culpable through inattention, or failing to avoid distraction. Most importantly, it was the very youngest drivers who experienced accidents that were associated with failure to search for conflicting traffic. In the 15–19 year old group, 39% of accidents had some contribution from this factor, with the next most frequent contributor being failure to comply with the road rules (right of way accidents), at 18% of all accidents. If young drivers have difficulty in adequately searching the roadway before making a manoeuvre such as a lane-change or when entering a main road from a side road, then this would open the possibility for accident reduction through more extensive training in preparation for the driver licensing test. A difficulty in relying upon written police reports of accidents is that they are based more upon judgement than upon direct observation. We have previously reported behavioural evidence of inadequate search by novice drivers that does support the Lestina and Miller conclusion, however (Crundall and Underwood, 1998). The purpose of the present report is to extend the analysis of road-search behaviour, to determine the source of the information being used by novice and experienced drivers as they perform specific manoeuvres.

Our previous study of the inspection of the road environment, as drivers encounter different road types, found that novice drivers did not differentiate between rural, suburban and dual-carriageway roads whereas on the dual-carriageway our experienced drivers increased their searches markedly however (Crundall and Underwood, 1998). The dependent measure of importance in that study was the variance of the search in the horizontal plane, using eye fixation data taken from a head-mounted eye-tracker. When drivers look straight ahead there is little variance of fixation position, but as they look around to check on the position and speed of traffic in adjacent lanes, then the variance increases. We found that this measure of location variance increased on the dual-carriageway for the drivers with 9 years of driving experience, relative to other road types, but that there was no such increase for drivers who had recently completed their driving test. The task being performed by the drivers in this study was a lane change on a dual-carriageway in which there was fast-moving traffic in the lane that was to be entered. Before entering this lane the

positions of the vehicles moving in the lane must be established in order to determine whether a gap is available, and the experienced drivers reflected this task by looking around them more than they had done on other roads. The novices showed no noticeable difference in their search behaviour in comparison with how they searched rural and suburban roads. An important question here is whether the novices were unaware of the danger involved in performing a lane-change in fast-moving traffic, or whether they had an inadequate level of vehicle-control skill to be able to collect more information than they were already processing.

The novices tested by Crundall and Underwood (1998) may have been unaware of the difficulty of making a lane-change on a dual-carriageway, or they may have been unable to do anything more than to maintain the vehicle’s current speed, headway and lane-position. The first option here is that the mental model of the driving task is incomplete for novice drivers, perhaps because they have little experience of driving on dual-carriageways. At the time the study was conducted, it was not necessary for a trainee driver to experience dual-carriageway driving at all, and driving on these roads was not a necessary part of the driver licensing test. If our novices were unaware of the potential hazards that are associated with changing lanes then there would be little reason for them to increase their search for these hazards. The second option is that the novices were under-skilled and that the components of the driving task such as steering to maintain one’s lane position, and maintaining the required engine speed through gear changes, were not fully automatised (Underwood and Everatt, 1996). If all of a driver’s attention is occupied by the task of controlling the vehicle, then there would be little opportunity for collecting new information about neighbouring traffic.

There are two sources of evidence to suggest that novice drivers had developed a ‘situation awareness’ that enabled them to appreciate the increased difficulty associated with dual-carriageways, and that their difficulty is in the amount of attention required for controlling the vehicle. Crundall and Underwood (1998) reported that there was an indication of novices having longer fixation durations on the dual-carriageway, suggesting an increase in the cognitive load associated with the difficulty of the lane-change that was required. Longer fixations are associated with increasing difficulty in reading tasks (e.g., Rayner, 1999; Underwood, 1984, Underwood, Clews and Everatt, 1990), and in a laboratory task in which we showed video clips recorded from a moving vehicle, novice drivers again had longer fixations than experienced drivers, especially when viewing dangerous situations (Chapman and Underwood, 1998). We tentatively conclude that the novices implicitly recognised the difficulty of the lane-change manoeuvre, but did not increase their search in response to their recognition of this difficulty. This straightforward interpretation is confounded by drivers having long fixations on the rural road, but this is most likely a product of a non-demanding road requiring little search.

The second source of evidence suggestive of an adequate mental model in novice drivers comes from a laboratory study using video clips of the same roads used in the original comparison of road types (Underwood, Dobson, Chapman and Crundall, 2001). Eye-tracking measures were again taken as novices and experienced drivers watched video clips taken from a car driven along the same route as we used in the Crundall and Underwood (1998) study, with a button-pressing hazard detection task. If the novices were unaware of the hazards on dual-carriageways, then their fixation patterns should be uniform across the three road-types. Alternatively, if their fixations when driving were limited by their available attention, then they should show the same increase in search patterns as the experienced drivers. Novices may

have not fully automatised their sub-routines for the operation control of the vehicle, and by eliminating this aspect of the task resources would then be available for scene inspection (Crundall, Underwood and Chapman, 1999). The laboratory study found that both types of drivers increased their horizontal scanning when shown a video clip taken on a dual-carriageway. This is taken as suggesting that the novices had developed a similar mental model of the task of driving on a dual-carriageway, and that the differences in scanning when driving were a product of the relatively increased mental workload imposed on novice drivers.

One difficulty in interpreting the report by Crundall and Underwood (1998) is that each driver experienced different traffic conditions, and this problem was addressed in the video experiment using the same design but with the same stimuli shown to all drivers. A second difficulty is that the most sensitive measure of individual driver differences was a rather crude measure of variance in the location of fixations. As drivers encounter specific road traffic conditions, they should search for information specific to those conditions. When drivers overtake slower moving vehicles on a typical rural road, for example, it is crucial to know that the opposing carriageway is clear of oncoming traffic and that they is not in the process of being overtaken by a faster vehicle themselves. Similarly, when preparing to manoeuvre into an outer lane of a dual-carriageway, it is important to know when a gap in the traffic is available, and to do this it is necessary to monitor the images in the door mirror.

The present study compared the use of mirrors in novice and experienced drivers as they perform lane-changing manoeuvres on a dual-carriageway similar to the road used by Crundall and Underwood (1998). Robinson, Erickson, Thurston and Clark (1972) have demonstrated that, for experienced drivers, mirror checks are sensitive to the presence or absence of traffic, and Recarte and Nunes (2000) found that mirror checks are sensitive to road complexity. The present study looks at mirror use both as a function of driver experience and road complexity. As part of a longer observation of their driving behaviour, volunteers made a safe change into an inside filter lane, a safe change into on offside lane on a slip road, and a more hazardous change to an offside lane where inter-weaving with current traffic was necessary. The extent of mirror checking is used to determine whether the increased horizontal variance previously seen in experienced drivers is, in part, a result of the increased inspection of their driving mirrors.

2. Method

2.1 Participants

A total of 42 participants, 21 experienced drivers and 21 novice drivers, aged from 17 to 30, took part in this study. Experienced drivers were recruited with an advertisement in the local evening newspaper, and novice drivers were recruited with the help of the Driving Standards Agency. The novice drivers were recruited immediately after they had passed their driving test. The experienced drivers had an average driving experience of 9 years, and the novices were tested within a few weeks of being recruited. The mean age of the experienced drivers was 27 years and the mean for the novices was18 years. All drivers were paid for their participation.

2.2 Materials

The participants were required to drive on a fixed test route in a test car equipped with two video cameras positioned inside the car and near to the internal driving mirror and near to the driver’s door mirror. These cameras were directed towards the driver’s eyes. A third video camera was directed forwards, and was used to identify the field of view of the driver and the section of road being travelled. The video images of the drivers’ direction of gaze and field of view were recorded via a multiplexer to a single VHS videotape. A Panasonic VHS video player and a Panasonic Editing Controller were used to collect and analyse the data from the original car tapes. The visual angle subtended by the line of sight when looking directly ahead and the line of sight when looking at the internal driving mirror was 40 degrees, and the angle to the external door mirror was 41 degrees.

2.3 Design and Procedure

The study used a mixed design, comparing experienced and novice drivers, three sections of roadway, and the use of two mirrors.

The three sections of roadway required different manoeuvres. In the first section the drivers were required to make one change of lane to the left. The section started at a signal-controlled junction, and with no competing traffic in the destination-lane, The manoeuvre was required in order to obtain access to a filter lane at a roundabout at the end of the section. The second section consisted of a two-lane slip-road leading from this roundabout to a multi-lane trunk road. Drivers prepared to enter the multi-lane carriageway by moving to the right lane of the slip-road. In the third section drivers had to move a further lane to the right. This section of roadway consisted of the two lanes of slip-road merging with two further lanes of trunk road. At the end of this section the four lanes diverged into two two-lane trunk roads, and traffic from the two right-hand lanes frequently made lane change manoeuvres to join the exiting trunk road to the left. Opposite changes are made by the traffic emerging from the slip-road, in order to joint the exiting trunk road to the right. These cross-over manoeuvres required vehicle integration and driver awareness of proximal traffic.

The chosen roadway was a part of the A453 dual carriageway from Nottingham towards Clifton. Each section took a minimum of 15 seconds to drive and had clearly defined environmental markers that were used as start points for the purpose of analysis. The drive was undertaken as part of a longer drive, and participants were not alerted to the significance of the three sections of interest to this study, or to the environment markers that were to be used in the analysis.

3. Results

The recordings taken were duration of fixations in the direction of two mirrors, as a function of driving experience and as a function of road layout. Fixations were identified with a frame-by-frame analysis of the recording taken from each mirror camera. The sampling rate was 25 frames per second. A fixation was defined by the driver’s eyes being fully directed at a given mirror camera. For each of three resultant measures – number of fixations made, total inspection time allocated to each mirror, and the average duration of fixations – separate analyses were performed. A fixation was defined as the period between the end of an eye movement that resulted in inspection of a mirror, and the start of a movement to take the eye away from inspection of the mirror. Fixations were therefore uninterrupted periods of inspection.

The total inspection time was the total duration of all fixations on each mirror during each 15-sec sampling period. This is a measure of the total amount of visual attention given to each mirror, independent of the number of separate glances made by the driver.

For number of fixations and total inspection time, each analysis of variance (anova) used one between-subjects factor (driving experience) and two within-subjects factors (road layout, and mirror inspected). Sometimes a driver did not look at a mirror during the sampling period, and for the analyses of number of fixations and total inspection time this was scored as zero fixations and as zero msec respectively. For the analysis of fixation duration, where we were interested in variations of actual fixations, this neglect of a mirror resulted in missing cells, and so a separate procedure was adopted, whereby two analyses were performed upon data averaged over different conditions. This produced one anova comparing drivers (between-subjects) and mirrors (within-subjects), and one anova comparing drivers (between-subjects) and road layout (within-subjects).

3.1 Number of fixations

The number of fixations made in the direction of the internal driving mirror and the external door mirror are presented in Table 1, as a function of road layout and driving experience. An analysis of variance indicated a main effect of road type (F2,80 = 9.5, p < 0.001). Scheffé comparisons indicated reduced use of mirrors in zone B (1.14 fixations), the two-lane slip-road, relative to zone A (1.68 fixations) when entering a near-side filter lane, and relative to zone C (1.87 fixations), when entering the main carriageway1. There was also a main effect of mirror used (F1,40 = 17.7, p < 0.001), with a greater number of glances towards the external door mirror (1.96 fixations) relative to the internal driving mirror (1.17 fixations), and there was no effect of driving experience (F < 1).

Mirror used interacted with both driving experience (F1,40 = 7.7, p < 0.01), and with road type (F2,80 = 21.1, p < 0.001), and these two interactions were analysed by inspecting the simple main effects. There was no reliable interaction between experience and road zone (F<1), and no reliable three-way interaction (F<1).

Whereas experienced drivers used the two mirrors to different extents, relying more on the external door mirror (F1,40 = 24.4, p < 0.001), novice drivers did not use the mirrors selectively (F1,40 = 1.0). There was no reliable effect of experience in the use of the internal mirror (F1,80 = 3.1), but experienced drivers looked more often in the external mirror (F1,80 = 5.1, p < 0.01).

Table 1. Numbers of glances in each mirror as a function of driving

experience and road type. (Standard deviations are in brackets.)

1Paired comparisons, here and throughout, are reported only if

reliable at p < 0.05 or better.

Zone A (Entering

the filter lane)Zone B

(Slip-road)

Zone C

(Entering the main

dual-carriageway)

Internal mirror External

mirror

Internal

mirror

External

mirror

Internal

mirror

External

mirror

Experienced drivers 1.33

(1.2)

2.00

(1.3)

0.81

(0.9)

1.62

(1.1)

0.67

(0.9)

3.14

(1.5)

Novice drivers

2.00

(2.0)

1.38

(1.1)

1.24

(1.3)

0.90

(1.1)

0.95

(1.0)

2.71

(1.9) The second interaction involved mirrors and road zone, with greater use of the

external door mirror only in zone C, when entering the main carriageway (F1,120 = 57.9, p < 0.001). In the other zones there was no difference in the use of the two mirrors (both F < 1).

3.2 Total inspection time

For each mirror in each road zone we aggregated the durations of all fixations to produce a measure of the total amount of visual attention given to that mirror. If no fixations were made, then a value of 0 msec was entered into this analysis, to reflect the neglect of the mirror. The means are presented in Table 2, as a function of mirror, roadway, and driving experience. The means for each driver were entered in an analysis of variance that indicated a main effect of road type (F2,80= 28.88, p< 0.001). Scheffé comparisons indicated that in zone C, entering the main carriageway (1620 msec) mirrors received more attention than in either zone A, entering the near-side filter lane (762 msec) or in zone B, on the two-lane slip-road (681 msec). The anova also revealed a main effect of mirror used (F1,40 = 24.46, p < 0.001), with more attention given to the external mirror (1397 msec) than to the interior mirror (645 msec). There was no main effect of driving experience (F < 1).

Two interactions emerged from the anova. Driving experience interacted with mirror selected (F1,40 = 5.8, p < 0.05), and road type also interacted with mirror selected (F2,80 = 22.9, p < 0.001). These two interactions were further inspected with analyses of simple main effects. There was no reliable interaction between experience and road zone (F<1), and no reliable three-way interaction (F<1).

Table 2. Total inspection time (msec) for each mirror as a function of

driving experience and road type. The durations of all fixations made by

each driver during the sampling interval were aggregated in order to

derive this measure of accumulated visual attention. When no fixation was made a value of 0 msec was entered for this measure. (Standard deviations are in brackets.)

Zone A (Entering

the filter lane)Zone B

(Slip-road)

Zone C

(Entering the main

dual-carriageway)

Internal mirror External

mirror

Internal

mirror

External

mirror

Internal

mirror

External

mirror

Experienced drivers 575

(488)

991

(758)

406

(459)

1004

(640)

453

(467)

2796

(1626)

Novice drivers

796

(904)

686

(513)

690

(818)

627

(816)

952

(1068)

2280

(1931) Drivers gave the two mirrors different amounts of attention, with no effect of

driving experience in the use of the interior mirror (F1,80 = 2.9), but with experienced drivers looking longer than the novices in the exterior mirror (F1,80 = 4.2, p < 0.05). The experienced drivers spent more time looking in the exterior mirror than in their interior mirror (F1,40 = 27.1, p < 0.001), but this difference was not reliable for the novice drivers (F1,40 = 2.9).

The interior mirror was used to similar extents on the three sections of road (F<1), whereas the exterior mirror was used more selectively (F2,160 = 51.3, p < 0.001). There were no differences in the use of the interior and exterior mirrors in zone A (F<1) or in zone B (F<1), but a marked increase in the use of the exterior mirror in zone C, when the drivers were changing lane on the main carriageway (F1,120 = 68.9, p < 0.001).

Table 3. Mean duration of each fixation (msec) in each mirror as a

function of driving experience and road type. When no fixation was

made no value was entered for this measure, and therefore the means are

derived from varying cell sizes. (Standard deviations are in brackets.)

Zone A (Entering

the filter lane)Zone B

(Slip-road)

Zone C

(Entering the main

dual-carriageway)

Internal mirror External

mirror

Internal

mirror

External

mirror

Internal

mirror

External

mirror

Experienced drivers

438

(201)

490

(208)

480

(176)

566

(187)

461

(141)

669

(212)

Novice drivers

413

(161)

469

(142)

538

(150)

669

(165)

549

(151)

654

(303)

3.3 Durations of fixations

The mean duration of each fixation in each mirror is shown in Table 3, as a function of driver experience and road type. Not all drivers inspected each mirror on each section of road, and a few drivers neglected both mirrors during the 15-sec sampling period. These occasions were scored as 0 fixations and as 0 sec inspection in the previous analyses, but when estimating the durations of actual fixations it is appropriate to average only fixations that have been made. Introducing scores of 0 msec would result in an under-estimate of the real average. Excluding non-fixations from this analysis produces missing cells for the anova, and this was handled by conducting two analyses, one in which each driver’s fixations were averaged across the three road types, and one in which fixations were averaged across the two mirrors. For the first anova there were then no missing cells, as every driver looked into each mirror sometime during testing. For the anova averaged across mirrors we had some drivers producing no data because they had not looked into either mirror during one section of road. This anova was conducted with no data from 2 experienced drivers and no data from 5 novice drivers.

A two-factor anova with fixation durations averaged across road types was used to inspect the effects of driver experience and mirror use. All drivers contributed data to this analysis. A main effect of mirrors was found (F1,40 = 14.1, p < 0.001). There was no effect of experience (F1,40 = 2.5) and no interaction (F<1). The main effect of mirrors resulted from fixations in the interior mirror being briefer (469 msec) than those in the exterior mirror (581 msec).

A second two-factor anova was conducted on fixation data averaged over the two mirrors, to inspect the effects of experience and road type. The drivers who looked into neither mirror during any road section were excluded from this analysis. The anova revealed a main effect of road type (F2,64 = 5.9, p < 0.01), but no reliable effect of driving experience (F<1) and no reliable interaction (F<1). The main effect of road type was inspected using Scheffé comparisons. These indicated shorter fixations in mirrors in zone A (456 msec) relative to both zone

B (562 msec) and zone

C (590 msec). The fixations in zones B and C did not differ in duration.

3.4 Looking over the shoulder

The video recordings were also used to count the number of drivers who looked over their shoulders during each 15-sec sampling period. Neglect of a mirror may be associated with reliance upon direct inspection of the scene, and this would be indicated by frequent glances over the driver’s shoulder. For the first section of road, 15 experienced drivers and 14 novices looked over their shoulder. For the second section of road, the figures for experienced and novice drivers were 8 and 3 respectively, and for the third section the figures were 14 and 15 respectively. There is no evidence here that the novices were looking over their shoulders rather than looking in their mirrors.

4. Discussion

The experiment was designed to observe the use of driving mirrors as novice and experienced drivers manoeuvred three sections of roadway, completing a lane change in each section. We were concerned to know whether the increase in variance in the location of fixations along the horizontal plane, reported by Crundall and Underwood (1998) could be attributed to experienced drivers making greater use of their mirrors under demanding driving conditions. There were no overall differences between novice and experienced drivers in the analyses of the number of mirror glances, in the total amount of attention given to the mirrors, or in the durations of the fixations on the objects in the mirrors, but driving experience was evident in a number of specific effects that emerged in interactions.

Experienced drivers used their exterior mirrors more than novices. This result was evident in the analyses of the number of fixations made and the related measure of total inspection time. Novices did not use their mirrors selectively, whereas experienced drivers directed their attention more to the exterior mirror, where information about vehicles in the next traffic lane was available. As the required manoeuvre was to move into this lane, it is clearly important to collect information about existing traffic, and to identify a gap prior to execution of the manoeuvre. Both novice and experienced drivers did increase their use of the exterior mirror in the section of road where the lane change involved negotiations with fast-moving traffic on the main highway, but this increase in selectivity was most prominent for the experienced drivers. This pattern appeared both for the number of glances in each mirror and for the total amount of attention given to each mirror. As an indication of this selectivity, consider the ratio of the amount of time given to the external mirror against that given to the internal mirror (data in Table 2). For experienced drivers this ratio is 6.2 to 1, whereas for novices it is 2.4 to 1, when entering the main dual-carriageway.

The pattern of results with number of fixations was similar to that using total inspection time, suggesting that there is a very simple relationship between inspections and inspection time. This is not the case, because if inspection time were a multiplier of number of fixations and fixation duration, then all fixations would be of similar duration. The data in Table 3 suggests that fixation durations show sensitivity to the task in hand, and in particular fixations in the exterior mirror were more than 100 msec longer in duration than fixations in the interior mirror. The duration of a fixation is generally taken as an indication of the difficulty or quantity of material

being inspected, and this is supported here by the observation that the easiest section of roadway (entering an unobstructed filter lane with no competing traffic) attracted the shortest fixation durations. We can conclude that when drivers looked in their internal mirrors it was to confirm the presence of a following vehicle, but when they looked in their external mirror the workload was increasing and that this was indicated by the increased fixation duration of each glance. At this point they were assessing the nature of the hazardous manoeuvre required of them by calculating the speed of the adjacent traffic, and searching for a gap between vehicles in preparation for a lane change into a stream of traffic.

The most hazardous section of two-lane highway driven here was a section that required a cross-over or interweaving manoeuvre, and this section prompted both groups of drivers to increase their use of the external mirror to assess the traffic in their own destination lane. This section of driving was associated with a doubling or tripling of the use of the external mirror, but even on the relatively non-hazardous sections most of the drivers checked their mirrors. On these occasions the drivers were maintaining general surveillance, possibly as a matter of habit in preparation for a manoeuvre. Even though they may not have been expecting any difficulties, they were attentive.

Our previous study of driving on a dual-carriageway demonstrated an increase in the variance of horizontal fixation locations for experienced drivers, relative to other roads (Crundall and Underwood, 1998), and the present results suggest that at least part of this increase can be attributed to increased use of the external mirror by these drivers. Novice drivers look around themselves less than experienced drivers to search for potential hazards and to maintain a general awareness of the locations of the neighbouring vehicles. One residual question concerns the awareness of novice drivers of the need to maintain their surveillance in general, and the search for hazardous events in particular. Our novices may have searched the surrounding roadway less than the experienced drivers because they had an under-developed ‘situation awareness’ of the needs of the task of lane-changing that was set them here (the incomplete mental model hypothesis). Alternatively, their mental resources may have been so completely consumed by the task of controlling the vehicle that they had no opportunity to collect information about the neighbouring traffic (the mental resources hypothesis). As already mentioned, there are two sources of evidence that suggest that novices are aware of the needs of the task, in that their fixation durations increased as the workload on the dual-carriageway increased (Crundall and Underwood, 1998), and in a laboratory task that placed no demands upon their driving skills they inspected a video of a dynamic roadway scene their search patterns resembled those of experienced drivers (Underwood et al., 2001). In the study presented here, there is also evidence of novices varying their behaviour as the task demands are increased. When they entered the most demanding section of the test route, they made increased use of the exterior mirror. This was not as marked an increase as that shown by the experienced drivers, but it is an indication of the sensitivity of their behaviour as the driving task changed in difficulty.

The two hypotheses are not necessarily independent, of course, and Brown and Groeger (1988) have described hazard detection as a joint function of experience and vehicle-handling skill. Experience provides an opportunity to encounter hazardous situations that are remembered and that subsequently modify the driver’s behaviour when similar circumstances prevail. At the same time, an increase in driving experience helps in the development of vehicle control skill and the gradual

automatisation of some of these skills serves to release mental resources for tasks such as surveillance.

There is a further explanation of the reliance of the novice drivers upon the internal mirror at times when crucial information is available only in the external mirror. When making a lane change into a lane of fast-moving traffic, in which vehicle integration required awareness of the locations of vehicles in the offside lane, more reliable information is available in the external mirror than in the internal mirror. The internal mirror provides excellent information about vehicles directly behind, and about vehicles following at some distance in all lanes. The external mirror provides information about adjacent vehicles in the destination lane prior to the lane-change manoeuvre. Both groups of drivers increased their use of the external mirror at the point in the test route when inter-weaving became necessary, but the novices did not use this mirror to the same extent as the experienced drivers. One possible explanation of this difference is that the novices had recently succeeded in a driver licensing test in which consultation of the interior mirror is stressed. Trainee drivers are encouraged to emphasize the way in which they look into the interior mirror, to ensure that their examiner has noted this behaviour, but consultation of the exterior mirror, which at times is more pertinent, is more difficult for examiners to monitor. It is this neglect in training and in the driver licensing examination that may spill-over into the driving behaviour of novices after they have successfully completed their training. Only with experience and with encounters of potentially hazardous situations do drivers learn to overcome this dependence upon their internal mirror. Acknowledgements

The UK Department of the Environment, Transport and the Regions and the UK Driving Standards Agency provided invaluable help in giving access to the recently qualified drivers. Gwendalina Fattori helped with data processing. A preliminary version of these results were presented at the International Conference on Traffic and Transport Psychology (September 2000) held in Berne, Switzerland.

References

BROWN, I. D. and GROEGER, J. A. 1988. Risk perception and decision taking during the transition between novice and experienced driver status.

Ergonomics, 31, 585-597.

CHAPMAN, P. R. and UNDERWOOD, G. 1998. Visual search of driving situations: Danger and experience. Perception, 27, 965-976.

CRUNDALL, D. E. and UNDERWOOD, G. 1998. Effects of experience and processing demands on visual information acquisition in drivers. Ergonomics, 41, 448-458.

CRUNDALL, D. E., UNDERWOOD, G. and CHAPMAN, P. R. 1999. Driving experience and the functional field of view. Perception, 28, 1075-1087. LESTINA, D. C. and MILLER, T. R. 1994. Characteristics of crash-involved younger drivers, in 38th Annual Proceedings of the Association for the Advancement of Automotive Medicine, Lyon, France.

RANNEY, T. A. 1994. Models of driving behavior: A review of their evolution.

Accident Analysis and Prevention,26, 733-750.

RAYNER, K. 1998. Eye movements in reading and information processing; 20 years of research. Psychological Bulletin, 124, 372-422.

RECARTE, M. A. and NUNES, L. M. 2000. Effects of verbal and spatial-imagery tasks on eye fixations while driving. Journal of Experimental Psychology: Applied, 6, 31-43.

ROBINSON, G. H., ERICKSON, D. J., THURSTON, G. L. and CLARK, R. L. 1972.

Visual search by automobile drivers. Human Factors, 14, 315-323. UNDERWOOD, G. 1985. Eye movements during the comprehension of written language, in A. W. Ellis (editor), Progress in the Psychology of Language, Volume 2. Erlbaum Associates: London.

UNDERWOOD, G., CLEWS, S. and EVERATT, J. 1990. How do readers know where to look next? Local information distributions influence eye fixations.

Quarterly Journal of Experimental Psychology,42A, 39-65. UNDERWOOD, G., DOBSON, H., CHAPMAN, P. and CRUNDALL, D. 2001, in press. Eye movements during the inspection of dynamic traffic scenes, in A.

Gale, I. D. Brown, C. M. Haslegrave and S. P. Taylor (editors), Vision in Vehicles VIII. Oxford: Elsevier

UNDERWOOD, G. & EVERATT, J. 1996. Automatic and controlled information processing: the role of attention in the processing of novelty, in O. Neumann & A. F. Sanders (editors), Handbook of Perception and Action III: Attention.

London: Academic Press.

WHILE循环语句的翻译程序设计(递归下降法、输出三地址表示)

课程设计任务书 学生姓名:赵旭林专业班级:计算机0801班 指导教师:陈天煌工作单位:计算机科学与技术学院 题目: WHILE循环语句的翻译程序设计(递归下降法、输出三地址表示)初始条件: 理论:学完编译课程,掌握一种计算机高级语言的使用。 实践:计算机实验室提供计算机及软件环境。如果自己有计算机可以在其上进行设计。 要求完成的主要任务:(包括课程设计工作量及其技术要求,以及说明书撰写等具体要求) (1)写出符合给定的语法分析方法的文法及属性文法。 (2)完成题目要求的中间代码三地址表示的描述。 (3)写出给定的语法分析方法的思想,完成语法分析和语义分析程序设计。 (4)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 (5)设计报告格式按附件要求书写。课程设计报告书正文的内容应包括: 1 系统描述(问题域描述); 2 文法及属性文法的描述; 3 语法分析方法描述及语法分析表设计; 4 按给定的题目给出中间代码形式的描述及中间代码序列的结构设计; 5 编译系统的概要设计; 6 详细的算法描述(流程图或伪代码); 7 软件的测试方法和测试结果; 8 研制报告(研制过程,本设计的评价、特点、不足、收获与体会等); 9 参考文献(按公开发表的规范书写)。 时间安排: 设计安排一周:周1、周2:完成系统分析及设计。 周3、周4:完成程序调试及测试。 周5:撰写课程设计报告。 设计验收安排:设计周的星期五第1节课开始到实验室进行上机验收。 设计报告书收取时间:设计周的次周星期一上午10点。 指导教师签名: 2010年 11月 13日 系主任(或责任教师)签名: 2010年 11月 13日

FOR循环语句的翻译程序设计

目录 1 系统描述 (2) 1.1目的 (2) 1.2设计内容: (2) 1.3翻译过程 (2) 1.4初始条件: (3) 1.5 开发平台 (3) 2文法及属性文法的描述 (3) 3 语法分析表设计 (4) 3.1 LR分析概述 (4) 3.2 LR(0)分析表 (5) 3.3 LR语法分析过程的设计思想及算法 (7) 3.4 翻译方法 (8) 4 中间代码形式的描述及中间代码序列的结构设计 (8) 5简要的分析与概要设计 (9) 6详细的算法描述 (9) 6.1 main函数 (10) 6.2词法分析 (10) 6.3 语法分析 (12) 7 测试方法和测试结果 (13) 7.1测试过程 (13) 7.2 测试结论 (14) 8 研制报告 (14) 8.1研制过程 (14) 8.2本设计的评价 (15) 8.3个人心得体会 (15) 9 参考文献 (16) 本科生课程设计成绩评定表 (17)

FOR循环语句的翻译程序设计 ——LR方法、输出四元式 1 系统描述 1.1目的 通过设计、编制、调试一个FOR循环语句的语法及语义分析程序,加深对语法及语义分析原理的理解,实现词法分析程序对单词序列的词法检查和分析,并且实现对单词序列的语法分析、语义分析以及中间代码生成。 1.2设计内容: 本设计按照要求设计出for语句的简单文法,并使用LR分析法对用户输入的程序进行分析和翻译。 对下列正确的程序输入: for(i=0;i<10;i++) { m=m+i; } 结果程序要对该输入进行词法分析,然后利用LR分析法对词法分析后得到的单词序列进行语法分析,经过语法制导翻译显示出等价的四元式表示的中间代码。 对于错误的程序输入,如: for(i=0;i<10) { m=m+i; } 结果程序要指出程序出错。 1.3翻译过程

IF-ELSE条件语句的翻译程序设计(LL(1)法、输出三地址表示) 2

IF-ELSE条件语句的翻译程序设计 1 问题描述 要求用LL(1)自顶向下分析方法及三地址中间代码,对IF-THEN-ELSE条件语句完成编译各阶段过程,包括词法、语法、语义等分析。 2 问题分析及编译系统的概要设计 编译过程一般分为六个阶段的过程,可以由六个模块完成,它们称为词法分析程序、语法分析程序、语义分析程序、中间代码生成程序、代码优化程序、目标代码生成程序,此外,一个完整编译程序还必须包括“表格管理程序”和“出错处理程序”。 这次实验涉及到词法分析、语法分析、语义分析及表格管理和出错管理。其中,词法分析至少要能识别关键字“if”、“then”和“else”,标识符(即自定义变量),数字,和运算符等等;语法分析要分析程序结构的合法性,即是否为文法的句子;语义分析要能够语法制导翻译出中间代码(三地址)并将其输出;表格管理是指符号表;出错处理是指在语法分析时,所有非文法句子的错误类型处理. 3 文法及属性文法的定义 3.1 文法: 文法是用于描述语言的语法结构的形式规则(即语法规则)。这些规则必须是准确的、易于理解的以及有相当强的描述能力。由这种规则所产生的程序语言应有利于句子分析和翻译,而且,最好能通过这些规则自动产生有效的语法分析程序. IF-ELSE条件语句的文法如下所示: 0.A->EB 1.B->+EB|-EB|ε 2.E->FT 3.T->*FT|/FT|ε 4.F->i|(E) 或者能够更简洁一点: 0.S->if A THEN B ELSE C 1.A->m rop n

3.C->x=n arop m 4.rop->=|<|> 5.arop->+|-|*|/ 3.2 属性文法: 属性文法是在上下文无关文法的基础上,为每个文法符号(终结符或者非终结符)配备若干相关的“值”(与文法符号相关的属性)。 在一个属性文法中,对应于每个产生式A→a都有一套与之相关联的语义规则,每规 则的形式为:b:=f(c 1,c 2 ,…,c k )其中f是一个函数,而且或者①b是A的一个综合属性 并且c 1,c 2 ,…,c k 是产生式右边文法符号的属性或者②非终结符既可有综合属性也可有 继属性,文法开始符号的所有继承属性作为属性计算前的初始值。 属性文法为: if(VT[opr]=='=') //{"="判断}; { arr[d][1]=arr_i[opd]; arr[d][0]='='; arr[d][2]=id; arr[d][3]=' '; arr[d][4]=' '; id++; } else if(VT[opr]=='>') //{">"判断}; { arr[d][1]=arr_i[opd]; arr[d][0]='>'; arr[d][2]=id; arr[d][3]=' '; arr[d][4]=' '; id++; }

DO-WHILE循环语句的翻译程序设计

课程设计任务书 学生姓名:专业班级: 指导教师:工作单位:计算机科学与技术学院 题目: DO-WHILE循环语句的翻译程序设计(LL(1)法、输出三地址表示)初始条件: 理论:学完编译课程,掌握一种计算机高级语言的使用。 实践:计算机实验室提供计算机及软件环境。如果自己有计算机可以在其上进行设计。 要求完成的主要任务:(包括课程设计工作量及其技术要求,以及说明书撰写等具体要求) (1)写出符合给定的语法分析方法的文法及属性文法。 (2)完成题目要求的中间代码三地址表示的描述。 (3)写出给定的语法分析方法的思想,完成语法分析和语义分析程序设计。 (4)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 (5)设计报告格式按附件要求书写。课程设计报告书正文的内容应包括: 1 系统描述(问题域描述); 2 文法及属性文法的描述; 3 语法分析方法描述及语法分析表设计; 4 按给定的题目给出中间代码形式的描述及中间代码序列的结构设计; 5 编译系统的概要设计; 6 详细的算法描述(流程图或伪代码); 7 软件的测试方法和测试结果; 8 研制报告(研制过程,本设计的评价、特点、不足、收获与体会等); 9 参考文献(按公开发表的规范书写)。 时间安排: 设计安排一周:周1、周2:完成系统分析及设计。 周3、周4:完成程序调试及测试。 周5:撰写课程设计报告。 设计验收安排:设计周的星期五第1节课开始到实验室进行上机验收。 设计报告书收取时间:设计周的次周星期一上午10点。 指导教师签名: 2011年月日 系主任(或责任教师)签名: 2011年月日

DO-WHILE循环语句的翻译程序设计 (LL(1)法、输出三地址表示) 1. 系统描述 1.1 设计目的 通过设计、编制、调试一个DO-WHILE循环语句的语法及语义分析程序,加深对法及语义分析原理的理解,并实现词法分析程序对单词序列的词法检查和分析。 1.2 设计内容及步骤 对循环语句: DO〈赋值语句〉WHILE 〈表达式〉 (1)按给定的题目写出符合自身语法分析方法要求的文法和属性文法描述。 (2)按给定的题目给出语法分析方法的思想及分析表设计。 (3)按给定的题目给出中间代码序列的结构设计。 (4)完成相应的词法分析、语法分析和语义分析程序设计。 (5)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 2. 文法及属性文法的描述 2.1 文法描述 K -> do L while S L -> SP P -> ;SP | ε S -> iQE E -> TG G -> +TG | -TG | εT -> FR R -> *FR | /FR | εF -> (E) | i Q -> = | < | > 2.2 属性文法的描述

for循环语句的翻译

课程设计任务书 学生姓名:辛波专业班级:计算机0707班 指导教师:彭德巍工作单位:计算机科学与技术学院 题目: FOR循环语句的翻译程序设计(递归下降法、输出四元式) 初始条件: 理论:学完编译课程,掌握一种计算机高级语言的使用。 实践:计算机实验室提供计算机及软件环境。如果自己有计算机可以在其上进行设计。 要求完成的主要任务:(包括课程设计工作量及其技术要求,以及说明书撰写等具体要求) (1)写出符合给定的语法分析方法的文法及属性文法。 (2)完成题目要求的中间代码四元式的描述。 (3)写出给定的语法分析方法的思想,完成语法分析和语义分析程序设计。 (4)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 (5)设计报告格式按附件要求书写。课程设计报告书正文的内容应包括: 1 系统描述(问题域描述); 2 文法及属性文法的描述; 3 语法分析方法描述及语法分析表设计; 4 按给定的题目给出中间代码形式的描述及中间代码序列的结构设计; 5 编译系统的概要设计; 6 详细的算法描述(流程图或伪代码); 7 软件的测试方法和测试结果; 8 研制报告(研制过程,本设计的评价、特点、不足、收获与体会等); 9 参考文献(按公开发表的规范书写)。 时间安排: 设计安排一周:周1、周2:完成系统分析及设计。 周3、周4:完成程序调试及测试。 周5:撰写课程设计报告。 设计验收安排:设计周的星期五第1节课开始到实验室进行上机验收。 设计报告书收取时间:设计周的次周星期一上午10点。 指导教师签名: 2010年 01月 08日 系主任(或责任教师)签名: 2010年 01月 08日

WHILE循环语句的翻译程序设计(简单优先法、输出四元式)

WHILE循环语句的翻译程序设计(简单优先法、输出四元式) 1 需求说明或问题描述 1.1 问题描述 对C++中while循环语句的理解及分析,通过编译中的词法分析、语法分析、语义分析及中间代码生成等编译过程,用简单优先分析法分析并翻译while语句。 1.2 需求说明 1 写出符合给定的语法分析方法的文法及属性文法 2 完成题目要求的中间代码四元式的描述 3 写出给定的语法分析方法的思想,完成语法分析及语义分析程序设计 4 设计若干用例,上机通过测试 2 文法及语法设计 2.1文法及属性文法: 文法G=(V N ,V T ,P ,S) 其中V N={S , B, E, C, A, B, P, T} V T={w, (, ), { ,}, i, ;} P={ S -> w(B){E} E -> C C -> CA C -> A A -> iPA A -> i; P -> +|-|*|/ B -> iTi B-> i T -> >|<|>=|<=|== } 2.2 语法分析方法描述及语法分析表设计 2.2.1 语法分析方法描述: 简单优先分析法是按照文法符号(终极符和非终极符)的优先关系确定句柄的。 基本思想可设计如下,首先根据已知优先文法构造相应优先关系矩阵,并将

文法的产生式保存,设置符号栈S,步骤如下: (1)将输入符号串a1a2…a n#依次逐个存入符号栈S中,直到遇到栈顶符号a i的优先性>下一个待输入符号a j为止。 (2)栈顶当前符号a i为句柄尾,由此向左在栈中找句柄的头符号a k,即找到a k-1

WHILE循环语句的翻译程序设计.

WHILE循环语句的翻译程序设计(递归下降法、输出三地址表示) 1 系统描述 按照课程设计的要求,写一个能识别while循环语句的文法,通过一定的变换使它符合递归下降法的要求,然后按照这个文法编写一个程序,该程序能识别输入的语句是否符合while语句的文法,或者能不能通过文法的开始符号推导出该语句。 该程序应该包括词法分析器,能对输入的语句进行词法分析,然后再对结果进行语法分析。词法分析器应能识别关键字,标示 符,常量,操作符等。 该程序的语法分析器能对输入的语法进行分析,判断输入语句能否满足while循环语句的文法。通过递归下降的方法对语句进行分析,看能否通过开始符号推导出来。 该程序的语义分析器就是对分析结果进行输出,要求输出结果是 三地址形式的。 2 文法及属性文法的描述 2.1文法描述 语句 > ::= while (< 条件表达式 > (< 赋值语句 > | 语句 > <条件表达式> ::= (<标识符>|<无符号整数>)<条件运算符> (<标识符>|<无符号整数> <标识符> ::= <字母> (<字母>|<数字> <条件运算符> ::= > | < | = <无符号整数> ::= <数字>(<数字>

<赋值语句> ::= <标识符>=(<标识符> | <数字> <算术运算符> (<标识符> | <数字> <算术运算符> ::= + | - | * | / <赋值语句> ::= <标识符>=<标识符> | <数字> 2.2递归文法 while语句文法: S -> while (B S | i=E B -> E relop E relop -> < | = | > E -> E+E | E-E | E*E | E/E | (E | i | n 在编写程序的时候用到的是递归下降法,而递归下降法对文法的要求是不能包含左递归,对上述的文法进行消除左递归之后,得 到如下的递归文法: S -> while (B S | i=E B -> E relop E relop -> < | = | > E -> (E F | iF | nF F -> +EF | -EF | *EF | /EF | ε 2.3属性文法的描述 产生式属性文法 S -> while (B S1S.begin:=newlabel;

WHILE循环语句的翻译程序设计课设报告

1.题目:将WHILE语句转换成四元式的程序实现 设计内容及要求:设计一个语法制导翻译器,将WHILE语句翻译成四元式。要求:先确定一个定义WHILE语句的文法,为其设计一个语法分析程序,为每条产生式配备一个语义子程序,按照一遍扫描的语法制导翻译方法,实现翻译程序。对用户输入的任意一个正确的WHILE语句,程序将其转换成四元式输出(可按一定格式输出到指定文件中)。 1、系统描述 通过设计、编制、调试一个WHILE循环语句的语法及语义分析程序,加深对语法 及语义分析原理的理解,并实现词法分析程序对单词序列的词法检查和分析。用语法 制导完成语义分析,并将形成的中间代码以四元式的形式输出。 2 、文法及属性文法的描述 。 2.1 文法的描述 该文法的产生式如下所示: (1)S->while(B){E} (2)E->AE (3)E->A (4)A->iPA (5)A->i (6)B->iTi & (7)B->i 其中while、( 、) 、{ 、} 、P、T 、;和i均为终结符,而S、A、B、E这些大写字母均为非终结符。T表示比较运算符,P表示算术运算符,i表示合法标识符。 2.2 属性文法的描述 对该文法的属性文法描述如下: (1) S->while(B){E} prinf(if B goto E else goto next) (2) E->AE print = · (3) E->A print =

(4) A->i P A print(A= P (5) A->i; = i; (6) B->i T i print(B = T (7) B->i = i 3 、语法分析方法描述及语法分析表设计 | 3.1 语法分析表设计 3.1.1 文法的DFA

编译原理报告for循环语句的翻译程序

学号:0120810680326 课程设计 题目f or循环语句的翻译程序 学院计算机学院 专业软件工程 班级0803 姓名徐泽前 指导教师何九周 2011 年 6 月日

目录 1设计目的 (4) 2设计环境与工具 (4) 3设计任务要求与说明 (4) 4设计时间 (4) 5设计地点 (4) 6系统描述 (4) 7文法及属性文法的描述 (5) 7.1文法描述 (5) 7.1.1 FOR语句相关的产生式: (5) 7.1.2 布尔表达式: (5) 7.1.3 赋值表达式: (5) 7.2属性文法的描述 (5) 8 语法分析方法描述及语法分析表设计 (7) 8.1语法分析方法描述 (7) 8.2系统中使用的action和goto表(见附录1) (9) 9 给出中间代码形式的描述及中间代码序列的结构设计 (9) 10简要的分析与概要设计 (10) 11 详细的算法描述 (11) 11.1词法分析的数据结构设计与详细的流程图 (11) 11.2词法分析流程图 (11) 11.3语法制导翻译的数据结构与详细的设计图 (12) 11.3.1数据结构的设计 (12) 11.3.2算法描述 (13) 11.3.3程序流程图 (13) 12给出软件的测试方法和测试结果 (14) 12.1 FOR循环语句的测试 (14) 12.2词法分析出错处理 (15) 12.3语法分析出错处理 (16) 13收获与体会 (16) 14 参考文献 (17)

课程设计任务书 学生姓名:徐泽前专业班级:软件0803班 指导教师:何九周工作单位:计算机学院 题目: for循环语句的翻译程序 初始条件: 程序设计语言:主要使用C语言的开发工具,或者采用LEX、YACC等工具,也可利用其他熟悉的开发工具。算法:可以根据《编译原理》课程所讲授的算法进行设计。 要求完成的主要任务:(包括课程设计工作量及其技术要求,说明书撰写等具体要求) 1.明确课程设计的目的和重要性,认真领会课程设计的题目,读懂课程设计指导书的要求,学会 设计的基本方法与步骤,学会如何运用前修知识与收集、归纳相关资料解决具体问题的方法。严格要求自己,要独立思考,按时、独立完成课程设计任务。 2.主要功能包括:利用算符优先分析方法和思想对某些语句进行语法分析与语义分析,生成相 应的中间代码。正确运用语法规则,并能应用所学的方法解决存在的问题。语法分析方法及中间代码形式的描述、文法和属性文法的设计。 2.进行总体设计,详细设计:包括算法的设计和数据结构设计。系统实施、调试,合理使用出错 处理程序。 3.设计报告:要求层次清楚、整洁规范、不得相互抄袭。正文字数不少于0.3万字。包含内容: ①课程设计的题目。 ②目录。 ③正文:包括引言、需求分析、总体设计及开发工具的选择,设计原则(给出语法分析方法及中间代码形式的描述、文法和属性文法的设计),数据结构与模块说明(功能与流程图)、详细的算法设计、软件调试、软件的测试方法和结果、有关技术的讨论、收获与体会等。 ④结束语。 ⑤参考文献。 ⑥附录:软件清单(或者附盘)。 时间安排: 消化资料、系统调查、形式描述1天 系统分析、总体设计、实施计划3天 撰写课程设计报告书1天 指导教师签名: 2010年 6月 11日 系主任(或责任教师)签名: 2010年 6月 11日

do-while语句翻译程序

DO-WHILE循环语句的翻译程序设计 (LR方法、输出三地址表示) 1.系统描述 1.1设计目的 通过设计、编制、调试一个DO-WHILE循环语句的语法及语义分析程序,加深对语法及语义分析原理的理解,并实现词法分析程序对单词序列的词法检查和分析。 1.2设计内容及步骤 对循环语句:DO〈赋值语句〉WHILE 〈表达式〉 按给定的题目写出符合自身语法分析方法要求的文法和属性文法描述。 (1)按给定的题目给出语法分析方法的思想及分析表设计。 (2)按给定的题目给出中间代码序列的结构设计。 (3)完成相应的词法分析、语法分析和语义分析程序设计。 (4)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 2文法的描述 本程序所用的文法如下: G[S]: (1)S->do{E;}while(B) {if B.true goto B.true else goto B.false;} (2)B->I1 rop I2 {B.type=bool;B.val=I1.val rop I2.val;} (3)E->I1=I2 op I3 {I1.val=I2.val op I3.val;} (4)I->id {I.val=id.val;} 注意:rop is < or >,op is +,-,*,/, id is any number or identifier 由上可知,非终结符B表示布尔表达式,E表示赋值表达式 3.语法分析方法描述及语法分析表设计 3.1语法分析方法描述 本实验采用LR分析方法对DO-WHILE语句进行语法分析。LR分析法是一种能根据当前分析栈中的符号串(通常以状态表示)和向右顺序查看输入串的K个(K>=0)符号就能惟一的确定分析器的动作是移进还是归约和用哪个产生式归约,因而也就能惟一的确定句柄。LR分析法的归约过程是规范推导的逆过程,所以LR分析过程是一种规范过程。 一个LR分析器由3个部分组成: 总控程序,也可以称为驱动程序。对所有的LR分析器,总控程序是相同的。 分析表或分析函数。不同的方法分析表将不同,同一个方法采用的LR分析器不同时,分析表也不同,分析表表又可以分为动作(ACTION)表和状态转换(GOTO)表两个部分,它们都可以用二维数组表示。 分析栈,包括文法符号栈和相应的状态栈。它们均是先进后出栈。

FOR循环语句翻译程序设计简单优先法三地址码JAVA

学 号: 27 课内实践报告课程名称编译原理 题目FOR循环语句的翻译程序设计(简单优先法、输出三地址码) 学院计算机科学及技术专业计算机科学及技术班级1201 姓名李潇颖 指导教师林泓

2014年12月9日 课内实践任务书 学生姓名:李潇颖专业班级:计算机1201班 指导教师:林泓工作单位:计算机科学及技术学院 题目: FOR循环语句的翻译程序设计(简单优先法、输出三地址码) 初始条件: 理论:学完编译课程,掌握一种计算机高级语言的使用。 实践:计算机实验室提供计算机及软件环境。如果自己有计算机可以在其上进行设计。 要求完成的主要任务:(包括课内实践工作量及其技术要求,以及说明书撰写等具体要求) (1)写出符合给定的语法分析方法的文法及属性文法。 (2)完成题目要求的中间代码三地址码的描述。 (3)写出给定的语法分析方法的思想,完成语法分析和语义分

析程序设计。 (4)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 (5)设计报告格式按附件要求书写。课内实践报告书正文的内容应包括: 1 系统描述(问题域描述); 2 文法及属性文法的描述; 3 语法分析方法描述及语法分析表设计; 4 按给定的题目给出中间代码形式的描述及中间代码序 列的结构设计; 5 编译系统的概要设计; 6 详细的算法描述(流程图或伪代码); 7 软件的测试方法和测试结果; 8 研制报告(研制过程,本设计的评价、特点、不足、 收获及体会等); 9 参考文献(按公开发表的规范书写)。 时间安排: 设计安排一周:周1、周2:完成系统分析及设计。 周3、周4:完成程序调试及测试。 周5:撰写课内实践报告。 设计验收安排:设计周的星期五第1节课开始到实验室进行上机验收。

FOR循环语句的翻译程序设计(简单优先法、三地址码)JAVA资料

学号:0121210340527 课内实践报告 课程名称编译原理 题目FOR循环语句的翻译程序设计(简 单优先法、输出三地址码) 学院计算机科学与技术 专业计算机科学与技术 班级1201 姓名李潇颖 指导教师林泓 2014 年12 月9 日

课内实践任务书 学生姓名:李潇颖专业班级:计算机1201班 指导教师:林泓工作单位:计算机科学与技术学院 题目: FOR循环语句的翻译程序设计(简单优先法、输出三地址码)初始条件: 理论:学完编译课程,掌握一种计算机高级语言的使用。 实践:计算机实验室提供计算机及软件环境。如果自己有计算机可以在其上进行设计。 要求完成的主要任务:(包括课内实践工作量及其技术要求,以及说明书撰写等具体 要求) (1)写出符合给定的语法分析方法的文法及属性文法。 (2)完成题目要求的中间代码三地址码的描述。 (3)写出给定的语法分析方法的思想,完成语法分析和语义分析程序设计。 (4)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 (5)设计报告格式按附件要求书写。课内实践报告书正文的内容应包括: 1 系统描述(问题域描述); 2 文法及属性文法的描述; 3 语法分析方法描述及语法分析表设计; 4 按给定的题目给出中间代码形式的描述及中间代码序列的结构设计; 5 编译系统的概要设计; 6 详细的算法描述(流程图或伪代码); 7 软件的测试方法和测试结果; 8 研制报告(研制过程,本设计的评价、特点、不足、收获与体会等); 9 参考文献(按公开发表的规范书写)。 时间安排: 设计安排一周:周1、周2:完成系统分析及设计。 周3、周4:完成程序调试及测试。 周5:撰写课内实践报告。 设计验收安排:设计周的星期五第1节课开始到实验室进行上机验收。 设计报告书收取时间:设计周的次周星期一上午10点。 指导教师签名:年月日 系主任(或责任教师)签名:

for循环实例.

for循环实例 读取的是数组expr的行数,然后程序执行循环体(loopbody),所以expr有多少列,循环体就循环多少次。expr经常用捷径表达式的方式,即first:incr:last。 在for和end之间的语句我们称之为循环体。在for循环运转的过程中,它将被重复的执行。For循环结构函数如下: 1.在for循环开始之时,matlab产生了控制表达式。 2.第一次进入循环,程序把表达式的第一列赋值于循环变量index,然后执行循环体内的语句。 3.在循环体的语句被执行后,程序把表达式的下一列赋值于循环变量index,程序将再一次执行循环体语句。 4.只要在控制表达式中还有剩余的列,步骤3将会一遍一遍地重复执行。 10次。循环系数ii在第一次执行的时侯是1,第二次执行的时侯为2,依次类推,当最后一次执行时,循环指数为10。在第十次执行循环体之后,再也没有新的列赋值给控制表达式,程序将会执行end语句后面的第一句。注意在循环体最后一次执行后,循环系数将会一直为10。 环指数ii在第一次执行时为1,第二次执行时为3,依此类推,最后一次执行时为9。在第五次执行循环体之后,再也没有新的列赋值给控制表达式,程序将会执行end语句后面的第一句。注意循环体在最后一次执行后,循环系数将会一直为9。 循环指数ii在第一次执行时为1,第二次执行时为3,第三次执行时为7。循环指数在循环结束之后一直为7。

循环指数ii 在第一次执行时为行向量??? ???41,第二次执行时为??? ???54,第三次执行时为 ??????76。这个例子说明循环指数可以为向量。 例1 阶乘(factorial )函数 这种循环将会执行5次,ii 值按先后顺序依次为1,2,3,4,5。n_factorial 最终的计算结果为1ⅹ2ⅹ3ⅹ4ⅹ5=120。 例2 统计分析 执行如下算法: 输入一系列的测量数,计算它们的平均数和标准差。这些数可以是正数,负数或0。 答案: 这个程序必须能够读取大量数据,并能够计算出这些测量值的平均数和标准差。这些测量值可以是正数,负数或0。 因为我们再也不能用一个数来表示数据中止的标识了,我们要求用户给出输入值的个数,然后用for 循环读取所有数值。 下面的就是这个修定版本的程序。它允许各种输入值,请你自己验证下面5个输入值的

《For循环语句》

《F o r循环语句》教学设计 池州市第八中学杜亦麟 课题 2.4.1 For循环语句 教学内容 粤教版信息技术(选修1)《算法与程序设计》第二章《程序设计基础》第四节《程序的循环结构》第一小节《For循环语句》 教学目标 知识与能力: 1.理解循环结构的基本思想及For语句的执行过程。 2.培养和提高学生逻辑思维能力,使其可以独立完成简单循环结构算法的设计。 3.能够利用For循环语句实现循环结构,解决实际问题。 过程与方法: 1.通过简单的数学问题的分析、讲解,让学生掌握For循环语句语法知识,及其执行原理。 2.以任务驱动,学生分组合作探究的方式,进一步让学生理解For循环语句的基本思想,同时培养学生自主探究和合作学习的能力。 3.通过自评和互评活动,培养学生语言表达能力和归纳总结能力。 情感态度与价值观: 1.提高学生学习兴趣,培养学习的主动性和探究性。 2.培养学生团结协作精神,体验成功的快乐。 教学重点 1.掌握For循环语句的格式和功能; 2.理解For循环语句的执行过程。 教学难点 控制循环的条件、确定循环体的内容 教材分析 第二章是程序设计基础,也是全书的基础。它沿着分析问题、设计算法、编写程序等运用计算机解决问题之路,开始学习如何使用VB程序设计编写程序解决问题。本节课的主要内容For语句的基本格式、执行过程及语句的实际应用。又是本章的重点和难点内容。而循环结构是程序设计的三种基本结构之一,其作用是使一段程序反复执行。For循环语句在程序设计中频繁出现,也是三种结构中较难的一种,因此,学好本节课非常重要,本节课的学习会使学生对算法有一个更深刻的理解,为以后的程序设计打下一个良好的基础,也可以培养学生的创新能力、分析问题和解决问题的能力以及探究精神。

《编译原理》课程设计-DO-WHILE循环语句的翻译程序设计(LL(1)法、输出三地址表示)资料

012131087051 学号: 6 课程设计 题目编译原理 学院计算机科学与技术 专业计算机科学与技术 班级 姓名 指导教师 2015 年12 月7 日

课程设计任务书 学生姓名:专业班级: 指导教师:工作单位: 题目: while循环语句的翻译程序设计(LL(1)法、输出三地址表示)初始条件: 理论:学完编译课程,掌握一种计算机高级语言的使用。 实践:计算机实验室提供计算机及软件环境。如果自己有计算机可以在其上进行设计。 要求完成的主要任务:(包括课程设计工作量及其技术要求,以及说明书撰写等具体要求) (1)写出符合给定的语法分析方法的文法及属性文法。 (2)完成题目要求的中间代码三地址表示的描述。 (3)写出给定的语法分析方法的思想,完成语法分析和语义分析程序设计。 (4)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 (5)设计报告格式按附件要求书写。课程设计报告书正文的内容应包括: 1 系统描述(问题域描述); 2 文法及属性文法的描述; 3 语法分析方法描述及语法分析表设计; 4 按给定的题目给出中间代码形式的描述及中间代码序列的结构设计; 5 编译系统的概要设计; 6 详细的算法描述(流程图或伪代码); 7 软件的测试方法和测试结果; 8 研制报告(研制过程,本设计的评价、特点、不足、收获与体会等); 9 参考文献(按公开发表的规范书写)。 时间安排: 设计安排一周:周1、周2:完成系统分析及设计。 周3、周4:完成程序调试及测试。 周5:撰写课程设计报告。 设计验收安排:设计周的星期五第1节课开始到实验室进行上机验收。 设计报告书收取时间:设计周的次周星期一上午10点。 指导教师签名: 2011年 12月 23日 系主任(或责任教师)签名: 2011年 12月 23日

编译IF-ELSE条件语句的翻译程序设计(简单优先法、输出三地址表示)代码+报告

学号:0120910340205 编译课程设计 题目IF-ELSE条件语句的翻译程序设计(简单优先法、输出三 地址表示) 学院计算机科学与技术学院专业计算机科学与技术专业班级计算机科学与技术0902班姓名 指导教师郭羽成 2012 年 1 月 5 日

课程设计任务书 学生姓名:专业班级:计算机0902班 指导教师:郭羽成工作单位:计算机科学与技术学院 题目: IF-ELSE条件语句的翻译程序设计(简单优先法、输出三地址表示)初始条件: 理论:学完编译课程,掌握一种计算机高级语言的使用。 实践:计算机实验室提供计算机及软件环境。如果自己有计算机可以在其上进行设计。 要求完成的主要任务:(包括课程设计工作量及其技术要求,以及说明书撰写等具体要求) (1)写出符合给定的语法分析方法的文法及属性文法。 (2)完成题目要求的中间代码三地址表示的描述。 (3)写出给定的语法分析方法的思想,完成语法分析和语义分析程序设计。 (4)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 (5)设计报告格式按附件要求书写。课程设计报告书正文的内容应包括: 1 系统描述(问题域描述); 2 文法及属性文法的描述; 3 语法分析方法描述及语法分析表设计; 4 按给定的题目给出中间代码形式的描述及中间代码序列的结构设计; 5 编译系统的概要设计; 6 详细的算法描述(流程图或伪代码); 7 软件的测试方法和测试结果; 8 研制报告(研制过程,本设计的评价、特点、不足、收获与体会等); 9 参考文献(按公开发表的规范书写)。 时间安排: 设计安排一周:周1、周2:完成系统分析及设计。 周3、周4:完成程序调试及测试。 周5:撰写课程设计报告。 设计验收安排:设计周的星期五第1节课开始到实验室进行上机验收。 设计报告书收取时间:设计周的次周星期一上午10点。 指导教师签名: 2011年 11月 18日 系主任(或责任教师)签名: 2011年 11月 18日

WHILE循环语句的翻译程序设计(递归下降法,输出四元式)

武汉理工大学《数据结构》课内实践报告 学号:0121210340314 课内实践报告 课程名称编译原理 WHILE 循环语句的翻译程序设计 设计题目 (递归下降法,输出四元式)学院计算机科学与技术 专业班级计算机1203班 姓名闵丹枫 指导教师林泓 2014年12月8 日

武汉理工大学《数据结构》课内实践报告

课程设计任务书 学生姓名:闵丹枫专业班级:计算机1203班 指导教师:林泓工作单位:计算机科学与技术学院 题目:WHILE循环语句的翻译程序设计(递归下降法、输出四元式) 初始条件: 理论:学完编译课程,掌握一种计算机高级语言的使用。 实践:计算机实验室提供计算机及软件环境。如果自己有计算机可以在其上进行设计。 要求完成的主要任务:(包括课程设计工作量及其技术要求,以及说明书撰写等具体要求) (1)写出符合给定的语法分析方法的文法及属性文法。 (2)完成题目要求的中间代码四元式的描述。 (3)写出给定的语法分析方法的思想,完成语法分析和语义分析程序设计。 (4)编制好分析程序后,设计若干用例,上机测试并通过所设计的分析程序。 (5)设计报告格式按附件要求书写。课程设计报告书正文的内容应包括:1系统描述(问题域描述); 2文法及属性文法的描述; 3语法分析方法描述及语法分析表设计; 4按给定的题目给出中间代码形式的描述及中间代码序列的结构设计; 5编译系统的概要设计; 6详细的算法描述(流程图或伪代码); 7软件的测试方法和测试结果; 8研制报告(研制过程,本设计的评价、特点、不足、收获与体会等) 9参考文献(按公开发表的规范书写)。 时间安排: 设计安排一周:周1、周2:完成系统分析及设计。 周3、周4:完成程序调试及测试。 周5:撰写课程设计报告。 设计验收安排:设计周的星期五第1节课开始到实验室进行上机验收。 设计报告书收取时间:设计周的次周星期一上午10点。 指导教师签名: 2014 年9月1日

FOR循环语句教学设计

F O R循环语句教学设计 集团档案编码:[YTTR-YTPT28-YTNTL98-UYTYNN08]

F O R循环语句 一、教材分析:本节是《算法与程序设计》(选修)第二章第四节“程序的循环结构”中的内容。这一节的前面是顺序结构和选择结构,紧接FOR语句后面是DO语句和循环嵌套。本节课是FOR语句的初次学习,着重介绍FOR语句的基础知识:格式和执行过程,不涉及双重循环等较难的运用。循环结构是程序设计的三种基本结构之一,是程序设计的基础。 二、学情分析:在学习本课之前,学生已掌握VB程序的顺序结构和选择结构的程序执行流程,对条件语句有了较深的理解,并具有一定的算法基础和比较、归纳能力。 三、教学目标 1、知识与技能:: 1)掌握FOR循环语句的基本格式; 2)理解FOR循环语句的执行过程; 3)能用for循环结构编写简单的程序。 2、过程与方法: 1)培养学生分析问题,解决问题的能力。 2)能进一步理解用计算机解决问题的过程和方法。 3、情感态度与价值观:激发学生学习热情,培养学生学习的积极性。 四、教学重点、难点及确立依据: 教学重点:1、掌握FOR循环语句的基本格式; 2、理解FOR循环语句的执行过程; 教学难点:解决实际问题,编写简单程序。 五、教学方法:讲授法、任务驱动法 六、教学环境:机房 六、教学过程: 1、导入新课: 由故事引出本节课内容: 阿基米德与国王下棋,国王输了,国王问阿基米德要什么奖赏?阿基米德对国王说:我只要在棋盘上第一格放一粒米,第二格放二粒,第三格放四粒,第四格放八粒………按这个比例放满整个棋盘64个格子就行。国王以为要不了多少粮食,可一个粮仓的米还摆不完一半的棋格子,全部摆满后,你知道排满棋盘全部格子有多少米吗?请根据你所学的数学知识列出式子。 学生回答:2^0+2^1+2^2+……2^64 那用vb程序怎样进行计算呢?引出循环结构。 2、新课讲授: 在实际问题中会遇到具体规律性的重复运算问题,反映在程序中就是将完成特定任务的一组语句重复执行多次。重复执行的一组语句称为循环体,每重复一次循环体,都必须做出继续或者停止循环的判断,其依据就是判断一个特定的条件,成立与否,决定继续还是退出循环。 举例说明: Fori=1To10 s=s+i

DO-WHILE循环语句的翻译程序设计(简单优先法、输出四元式)

(二)DO-WHILE循环语句的翻译程序设计(简单优先法、输出四元式) 一、1.简单优先法的基本思想 根据优先关系的定义,将简单优先文法中各文法符号之间的这种关系用一个矩阵表示,称作简单优先矩阵。PDA读入一个单词后,比较栈顶符号和该单词的优先级,若栈顶符号优先级低于该单词,继续读入;若栈顶符号优先级高于或等于读入符号,则找句柄进行归约,找不到句柄就继续读入。直到最后栈内只剩下开始符号,输入串读到“#”为止。此时识别正确。可分点描述如下: (1)、对句型中相邻的文法符号规定优先关系,以寻找句型中的句柄; (2)、规定句柄内各相邻符号之间具有相同的优先级; (3)、规定句柄两端符号优先级要比位于句柄之外而又和句柄相邻的符号的优先级高,以先归约句柄; (4)、对于文法中所有符号,只要它们可能在某个句型中相邻,就要为它们规定相应的优先关系,若某两个符号永远不可能相邻,则它们之间就无关系. 2.简单优先矩阵 用于表示文法符号之间的简单优先关系的矩阵。 3.简单优先法的优缺点 优点:技术简单,当做简单优先矩阵是要求较短。 缺点:适用范围小,分析表尺寸太大。 二、源代码实现: #include #define MAX 35 #include #include #include using namespace std; #define TABLE_LEN 8 #define STR_LEN 256 int zhlen; char sTable[TABLE_LEN+1] = {"+-*/()i#"};//顺序索引 int ShipTable[TABLE_LEN][TABLE_LEN] = //优先表 { { 1, 1,-1,-1,-1, 1,-1, 1}, { 1, 1,-1,-1,-1, 1,-1, 1}, { 1, 1, 1, 1,-1, 1,-1, 1}, { 1, 1, 1, 1,-1, 1,-1, 1}, {-1,-1,-1,-1,-1, 0,-1,-2}, { 1, 1, 1, 1,-2, 1,-2, 1},

将高级语言源程序翻译成目标程序的翻译程序称为 D、

将高级语言源程序翻译成目标程序的翻 译程序称为D、 相关的主题文章: 2、汇编程序的作用是指将汇编语言源程序翻译成(A、可履行程序) 3、《中华人民共和国计算机信息系统平安维护条例》公布于(B、1994年) 4、LAN的中文名称是(B、局域网) 5、操作系统是为了提高计算机的工作效率和便利用户使用计算机而装备的一种(D、系统软件) 6、第二代电子计算机主要采用(A、晶体管)元件制作成 7、Windows98中,中英文输入法快捷键(C、ctrl空格) 8、Windows98中""表现(C、文件夹中还有子文件夹) 9、停止一个活动窗口的利用程序窗口(A、Alt F4) 10、Windows98中,对桌面背景的设置可以(鼠标右击桌面空缺处,选"属性") 11、资源管理器中,可以取舍多个持续的文件的操作是(B、shift)键 12、狭义的初级电算化是指(电子计算技巧在计算机中的运用) 13、期初余额的录入(A、在开始使用总账系统时必须录入期初余额) 14、增添会计科目顺序必须由(从下级到上级增长) 15、商品化的会计软件比自行开发的会计软件(A、通用性强、开发程度高) 16、3222的会计科目标编码计划,请问1010101科目是(三级明细科目)

17、会计报表系统中,最新计算机考试试题,运算公式应在(A、报表格式定义)之后实现 18、3 22构造的会计科目代码最多核算到(C、三级)级明细科目 19、已记过账的财务系统中,还是否增加科目(D、不能) 20、会计核算软件中采用的(总分类账)会计科目名称、编码方法必须吻合 国家统一会计制度的规定 21、字母大小写的转换键是(Capslock) 22、把硬盘上数据传递到计算机内存中去叫(B、读盘) 23、计算机病毒是(B、一种特别程序) 24、TCP指的是一种(B、传输节制协定) 25、IP地址采取(B、32)位二进制代码 26、存储器的叙述正确的是(C、CPU只能直接访问内存,而不能拜访外存) 27、设置会计科目编码要求(各部门财政部同一规定) 28、制定会计核算软件基本功能标准的根据是(《中华国民共和国会计法》和《会计电算化管理方式》) 29、财政部制订的《会计核算软件管理的多少项划定》时光是(C、1989年) 30、已经输入的机内的记账凭证,(B、不可以)直接登记入账 31、存储介质的特点(B) A、可以直观地看到 B、不能直观地看到,必须由计算机打印输出 C、可以通过复印方法保存 D、与手工方式相同 32、收付款凭证必须有的科目(B)

相关文档
最新文档