diff --git a/dat/dungeon.def b/dat/dungeon.def deleted file mode 100644 index d4d61fbaf..000000000 --- a/dat/dungeon.def +++ /dev/null @@ -1,143 +0,0 @@ -# NetHack 3.6 dungeon.def $NHDT-Date: 1462486876 2016/05/05 22:21:16 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.14 $ -# Copyright (c) 1990-95 by M. Stephenson -# NetHack may be freely redistributed. See license for details. -# -# The dungeon description file for the "standard" 3.1 NetHack. -# -# Note: The order of the definition of dungeons in this file -# reflects in their order of creation in the real dungeon. -# The "Main" branch must *always* be first. -# Also note that the order of the dungeons in this file -# determines the order in which branch levels are assigned. -# If two dungeons have overlapping ranges for their entry -# points, then you should list the dungeon with the _least_ -# number of choices for its branch level _first_. -# - -DUNGEON: "The Dungeons of Doom" "D" (25, 5) -ALIGNMENT: unaligned -BRANCH: "The Gnomish Mines" @ (2, 3) -LEVEL: "rogue" "R" @ (15, 4) -LEVELDESC: roguelike -LEVEL: "oracle" "O" @ (5, 5) -LEVALIGN: neutral -CHAINBRANCH: "Sokoban" "oracle" + (1, 0) up -RNDLEVEL: "bigrm" "B" @ (10, 3) 40 10 -CHAINBRANCH: "The Quest" "oracle" + (6, 2) portal -BRANCH: "Fort Ludios" @ (18, 4) portal -RNDLEVEL: "medusa" "none" @ (-5, 4) 4 -LEVALIGN: chaotic -LEVEL: "castle" "none" @ (-1, 0) -CHAINBRANCH: "Gehennom" "castle" + (0, 0) no_down -BRANCH: "The Elemental Planes" @ (1, 0) no_down up - -# -# Gehennom -# -# Now re-worked for 3.1, hell is hopefully going to be a little -# less boring. Also, in 3.1, the tower is not considered as a -# part of hell, but is set up as a separate dungeon. -# -# Gehennom is no longer considered "hellish" as a complete dungeon. -# That is, fire resistance is no longer a condition for survival in -# it. However, Gehennom, and the special levels in it in particular, -# is abundant with fire traps. As a result, fire resistance is still -# a prudent survival strategy in Gehennom. -# -# Note: Gehennom *must* be the second dungeon defined so that -# monsters can properly migrate here under certain -# circumstances. -# -DUNGEON: "Gehennom" "G" (20, 5) -DESCRIPTION: mazelike -DESCRIPTION: hellish -ALIGNMENT: noalign -BRANCH: "Vlad's Tower" @ (9, 5) up -LEVEL: "valley" "V" @ (1, 0) -LEVEL: "sanctum" "none" @ (-1, 0) -LEVEL: "juiblex" "J" @ (4, 4) -LEVEL: "baalz" "B" @ (6, 4) -LEVEL: "asmodeus" "A" @ (2, 6) -LEVEL: "wizard1" "none" @ (11, 6) -CHAINLEVEL: "wizard2" "X" "wizard1" + (1, 0) -CHAINLEVEL: "wizard3" "Y" "wizard1" + (2, 0) -LEVEL: "orcus" "O" @ (10, 6) -LEVEL: "fakewiz1" "F" @ (-6,4) -LEVEL: "fakewiz2" "G" @ (-6,4) - -# -# The Mines of the Gnomes of Zurich. -# -DUNGEON: "The Gnomish Mines" "M" (8, 2) -ALIGNMENT: lawful -DESCRIPTION: mazelike -RNDLEVEL: "minetn" "T" @ (3, 2) 7 -LEVELDESC: town -RNDLEVEL: "minend" "E" @ (-1, 0) 3 - -# -# The Questdungeon -# -# This is a proto-dungeon. The level file names will be prepended with -# three letter role abbreviation during initialization, replacing "x". -# A special "x-fill" level must be defined in the levels description -# file. It will be used for all levels not defined explicitly below. -# -DUNGEON: "The Quest" "Q" (5, 2) -LEVEL: "x-strt" "none" @ (1, 1) -LEVEL: "x-loca" "L" @ (3, 1) -LEVEL: "x-goal" "none" @ (-1, 0) - -# -# Sokoban -# -DUNGEON: "Sokoban" "none" (4, 0) -DESCRIPTION: mazelike -ALIGNMENT: neutral -ENTRY: -1 -RNDLEVEL: "soko1" "none" @ (1, 0) 2 -RNDLEVEL: "soko2" "none" @ (2, 0) 2 -RNDLEVEL: "soko3" "none" @ (3, 0) 2 -RNDLEVEL: "soko4" "none" @ (4, 0) 2 - -# -# The Central Vault of Croesus. -# -DUNGEON: "Fort Ludios" "K" (1, 0) -DESCRIPTION: mazelike -ALIGNMENT: unaligned -LEVEL: "knox" "K" @ (-1, 0) -# -# Vlad's Tower -# -# It has been removed from Gehennom, and it is surrounded by stone. -# Must not allow bones files for its top level. -# -DUNGEON: "Vlad's Tower" "T" (3, 0) -PROTOFILE: "tower" -DESCRIPTION: mazelike -ALIGNMENT: chaotic -ENTRY: -1 -LEVEL: "tower1" "none" @ (1, 0) -# it isn't necessary to list these last two, but doing so makes them -# show up in ^O output and in the level teleport menu -LEVEL: "tower2" "none" @ (2, 0) -LEVEL: "tower3" "none" @ (3, 0) - -# -# The Endgame levels -# -# Enter on 2nd level from bottom; 1st (from bottom) is a -# placeholder for surface level, and should be unreachable. -# [Note: the name "dummy" is checked for in init_dungeons().] -# -DUNGEON: "The Elemental Planes" "E" (6, 0) -DESCRIPTION: mazelike -ALIGNMENT: unaligned -ENTRY: -2 -LEVEL: "astral" "none" @ (1, 0) -LEVEL: "water" "none" @ (2, 0) -LEVEL: "fire" "none" @ (3, 0) -LEVEL: "air" "none" @ (4, 0) -LEVEL: "earth" "none" @ (5, 0) -LEVEL: "dummy" "none" @ (6, 0) diff --git a/dat/dungeon.lua b/dat/dungeon.lua new file mode 100644 index 000000000..6112a25ad --- /dev/null +++ b/dat/dungeon.lua @@ -0,0 +1,310 @@ + +dungeon = { + { + name = "The Dungeons of Doom", + bonetag = "D", + base = 25, + range = 5, + alignment = "unaligned", + branches = { + { + name = "The Gnomish Mines", + base = 2, + range = 3 + }, + { + name = "Sokoban", + chainlevel = "oracle", + base = 1, + direction = "up" + }, + { + name = "The Quest", + chainlevel = "oracle", + base = 6, + range = 2, + branchtype = "portal" + }, + { + name = "Fort Ludios", + base = 18, + range = 4, + branchtype = "portal" + }, + { + name = "Gehennom", + chainlevel = "castle", + base = 0, + branchtype = "no_down" + }, + { + name = "The Elemental Planes", + base = 1, + branchtype = "no_down", + direction = "up" + } + }, + levels = { + { + name = "rogue", + bonetag = "R", + base = 15, + range = 4, + flags = "roguelike", + }, + { + name = "oracle", + bonetag = "O", + base = 5, + range = 5, + alignment = "neutral" + }, + { + name = "bigrm", + bonetag = "B", + base = 10, + range = 3, + chance = 40, + nlevels = 10 + }, + { + name = "medusa", + base = -5, + range = 4, + nlevels = 4, + alignment = "chaotic" + }, + { + name = "castle", + base = -1 + } + } + }, + { + name = "Gehennom", + bonetag = "G", + base = 20, + range = 5, + flags = { "mazelike", "hellish" }, + alignment = "noalign", + branches = { + { + name = "Vlad's Tower", + base = 9, + range = 5, + direction = "up" + } + }, + levels = { + { + name = "valley", + bonetag = "V", + base = 1 + }, + { + name = "sanctum", + base = -1 + }, + { + name = "juiblex", + bonetag = "J", + base = 4, + range = 4 + }, + { + name = "baalz", + bonetag = "B", + base = 6, + range = 4 + }, + { + name = "asmodeus", + bonetag = "A", + base = 2, + range = 6 + }, + { + name = "wizard1", + base = 11, + range = 6 + }, + { + name = "wizard2", + bonetag = "X", + chainlevel = "wizard1", + base = 1 + }, + { + name = "wizard3", + bonetag = "Y", + chainlevel = "wizard1", + base = 2 + }, + { + name = "orcus", + bonetag = "O", + base = 10, + range = 6 + }, + { + name = "fakewiz1", + bonetag = "F", + base = -6, + range = 4 + }, + { + name = "fakewiz2", + bonetag = "G", + base = -6, + range = 4 + }, + } + }, + { + name = "The Gnomish Mines", + bonetag = "M", + base = 8, + range = 2, + alignment = "lawful", + flags = { "mazelike" }, + levels = { + { + name = "minetn", + bonetag = "T", + base = 3, + range = 2, + nlevels = 7, + flags = "town" + }, + { + name = "minend", + bonetag = "E", + base = -1, + nlevels = 3 + }, + } + }, + { + name = "The Quest", + bonetag = "Q", + base = 5, + range = 2, + levels = { + { + name = "x-strt", + base = 1, + range = 1 + }, + { + name = "x-loca", + bonetag = "L", + base = 3, + range = 1 + }, + { + name = "x-goal", + base = -1 + }, + } + }, + { + name = "Sokoban", + base = 4, + alignment = "neutral", + flags = { "mazelike" }, + entry = -1, + levels = { + { + name = "soko1", + base = 1, + nlevels = 2 + }, + { + name = "soko2", + base = 2, + nlevels = 2 + }, + { + name = "soko3", + base = 3, + nlevels = 2 + }, + { + name = "soko4", + base = 4, + nlevels = 2 + }, + } + }, + { + name = "Fort Ludios", + base = 1, + bonetag = "K", + flags = { "mazelike" }, + alignment = "unaligned", + levels = { + { + name = "knox", + bonetag = "K", + base = -1 + } + } + }, + { + name = "Vlad's Tower", + base = 3, + bonetag = "T", + protofile = "tower", + alignment = "chaotic", + flags = { "mazelike" }, + entry = -1, + levels = { + { + name = "tower1", + base = 1 + }, + { + name = "tower2", + base = 2 + }, + { + name = "tower3", + base = 3 + }, + } + }, + { + name = "The Elemental Planes", + bonetag = "E", + base = 6, + alignment = "unaligned", + flags = { "mazelike" }, + entry = -2, + levels = { + { + name = "astral", + base = 1 + }, + { + name = "water", + base = 2 + }, + { + name = "fire", + base = 3 + }, + { + name = "air", + base = 4 + }, + { + name = "earth", + base = 5 + }, + { + name = "dummy", + base = 6 + }, + } + }, +} diff --git a/doc/dgn_comp.6 b/doc/dgn_comp.6 deleted file mode 100644 index 7b311831c..000000000 --- a/doc/dgn_comp.6 +++ /dev/null @@ -1,419 +0,0 @@ -.TH DGN_COMP 6 "25 May 2015" NETHACK -.de ND -.ds Nd \\$3 -.. -.de NB -.ds Nb \\$2 -.. -.de NR -.ds Nr \\$2 -.. -.ND $NHDT-Date: 1524689548 2018/04/25 20:52:28 $ -.NB $NHDT-Branch: NetHack-3.6.0 $ -.NR $NHDT-Revision: 1.6 $ -.ds Na Kenneth Lorber - -.SH NAME -dgn_comp \- NetHack dungeon compiler -.SH SYNOPSIS -.B dgn_comp -[ -.I file -] -.PP -If no arguments are given, it reads standard input. -.SH DESCRIPTION -.PP -.I Dgn_comp -is a dungeon compiler for NetHack version 3.2 and higher. It -takes a description file as an argument and produces a dungeon "script" -that is to be loaded by NetHack at runtime. -.PP -The purpose of this tool is to provide NetHack administrators and -implementors with a convenient way to create a custom dungeon for the -game, without having to recompile the entire world. -.SH GRAMMAR -.PP -DUNGEON: -.B name -.B bonesmarker -( -.B base -, -.B rand -) [ -.B %age -] -.PP -where -.B name -is the dungeon name, -.B bonesmarker -is a letter for marking bones files, ( -.B base -, -.B rand -) is the number of levels, and -.B %age -is its percentage chance of being generated (if absent, 100% chance). - -DESCRIPTION: -.B tag -.PP -where -.B tag -is currently one of -.BR HELLISH , -.BR MAZELIKE , -or -.BR ROGUELIKE . - -ALIGNMENT | LEVALIGN: [ -.B lawful -| -.B neutral -| -.B chaotic -| -.B unaligned -] -.PP -gives the alignment of the dungeon/level (default is unaligned). - -ENTRY: -.B level -.PP -the dungeon entry point. The dungeon connection attaches at this -level of the given dungeon. -If the value of -.B level -is negative, the entry level is calculated from the bottom of the -dungeon, with -1 being the last level. -If this line is not present in a dungeon description, the entry level -defaults to 1. - -PROTOFILE: -.B name -.PP -the prototypical name for dungeon level files in this dungeon. -For example, the PROTOFILE name for the dungeon -.I Vlad's Tower -is -.IR tower . - -LEVEL: -.B name -.B bonesmarker -@ ( -.B base -, -.B rand -) [ -.B %age -] -.PP -where -.B name -is the level name, -.B bonesmarker -is a letter for marking bones files, ( -.B base -, -.B rand -) is the location and -.B %age -is the generation percentage, as above. - -RNDLEVEL: -.B name -.B bonesmarker -@ ( -.B base -, -.B rand -) -[ -.B %age -] -.B rndlevs -.PP -where -.B name -is the level name, -.B bonesmarker -is a letter for marking bones files, ( -.B base -, -.B rand -) is the location, -.B %age -is the generation percentage, as above, and -.B rndlevs -is the number of similar levels available to choose from. - -CHAINLEVEL: -.B name -.B bonesmarker -.B prev_name -+ ( -.B base -, -.B rand -) [ -.B %age -] -.PP -where -.B name -is the level name, -.B bonesmarker -is a letter for marking bones files, -.B prev_name -is the name of a level defined previously, ( -.B base -, -.B rand -) is the -.I offset -from the level being chained from, and -.B %age -is the generation percentage. - -RNDCHAINLEVEL: -.B name -.B bonesmarker -.B prev_name -+ ( -.B base -, -.B rand -) [ -.B %age -] -.B rndlevs -.PP -where -.B name -is the level name, -.B bonesmarker -is a letter for marking bones files, -.B prev_name -is the name of a level defined previously, ( -.B base -, -.B rand -) is the -.I offset -from the level being chained from, -.B %age -is the generation percentage, and -.B rndlevs -is the number of similar levels available to choose from. - -LEVELDESC: -.B type -.PP -where -.B type -is the level type, (see DESCRIPTION, above). The -.B type -is used to override any pre-set value used to describe the entire dungeon, -for this level only. - -BRANCH: -.B name -@ ( -.B base -, -.B rand -) [ -.B stair -| -.B no_up -| -.B no_down -| -.B portal -] [ -.B up -| -.B down -] -.PP -where -.B name -is the name of the dungeon to branch to, and ( -.B base -, -.B rand -) is the location of the branch. -The last two optional arguments are -the branch type and branch direction. -The type of a branch can be a two-way stair connection, -a one-way stair connection, or a magic portal. -A one-way stair is described by the types -.B no_up -and -.B no_down -which specify which stair direction is missing. -The default branch type is -.BR stair . -The direction for a stair can be either up or down; direction is not -applicable to portals. The default direction is -.BR down . - -CHAINBRANCH: -.B name -.B prev_name -+ ( -.B base -, -.B rand -) [ -.B stair -| -.B no_up -| -.B no_down -| -.B portal -] [ -.B up -| -.B down -] -.PP -where -.B name -is the name of the dungeon to branch to, -.B prev_name -is the name of a previously defined -.B level -and ( -.B base -, -.B rand -) is the -.I offset -from the level being chained from. -The optional branch type and direction are the same as described above. -.SH GENERIC RULES -.PP -Each dungeon must have a unique -.B bonesmarker , -and each special level must have a -.B bonesmarker -unique within its dungeon (letters may be reused in different dungeons). -If the -.B bonesmarker -has the special value "none", no bones files will be created for that -level or dungeon. -.PP -The value -.B base -may be in the range of 1 to -.B MAXLEVEL -(as defined in -.I global.h -). -.PP -The value -.B rand -may be in the range of -1 to -.BR MAXLEVEL . -.PP -If -.B rand -is -1 it will be replaced with the value (num_dunlevs(dungeon) - base) -during the load process (ie. from here to the end of the dungeon). -.PP -If -.B rand -is 0 the level is located absolutely at -.BR base . -.PP -Branches don't have a probability. Dungeons do. If a dungeon fails -to be generated during load, all its levels and branches are skipped. -.PP -No level or branch may be chained from a level with a percentage generation -probability. This is to prevent non-resolution during the load. -In addition, no branch may be made from a dungeon with a percentage -generation probability for the same reason. -.PP -As a general rule using the dungeon compiler: -.PP -If a dungeon has a -.B protofile -name associated with it -.RI ( eg. -.BR tower ) -that file will be used. -.PP -If a special level is present, it will override the above rule and -the appropriate file will be loaded. -.PP -If neither of the above are present, the standard generator will -take over and make a "normal" level. -.PP -A level alignment, if present, will override -the alignment of the dungeon that it exists within. -.SH EXAMPLE -.PP -Here is the current syntax of the dungeon compiler's "language": - -.LP -.nf -.ta +8n +8n +8n -# -# The dungeon description file for the "standard" original -# 3.0 NetHack. -# -DUNGEON: "The Dungeons of Doom" "D" (25, 5) -LEVEL: "rogue" "none" @ (15, 4) -LEVEL: "oracle" "none" @ (5, 7) -LEVEL: "bigroom" "B" @ (12, 3) 15 -LEVEL: "medusa" "none" @ (20, 5) -CHAINLEVEL: "castle" "medusa" + (1, 4) -CHAINBRANCH: "Hell" "castle" + (0, 0) no_down -BRANCH: "The Astral Plane" @ (1, 0) no_down up - -DUNGEON: "Hell" "H" (25, 5) -DESCRIPTION: mazelike -DESCRIPTION: hellish -BRANCH: "Vlad's Tower" @ (13, 5) up -LEVEL: "wizard" "none" @ (15, 10) -LEVEL: "fakewiz" "A" @ (5, 5) -LEVEL: "fakewiz" "B" @ (10, 5) -LEVEL: "fakewiz" "C" @ (15, 5) -LEVEL: "fakewiz" "D" @ (20, 5) -LEVEL: "fakewiz" "E" @ (25, 5) - -DUNGEON: "Vlad's Tower" "T" (3, 0) -PROTOFILE: "tower" -DESCRIPTION: mazelike -ENTRY: -1 - -DUNGEON: "The Astral Plane" "A" (1, 0) -DESCRIPTION: mazelike -PROTOFILE: "endgame" -.fi -.PP -.I NOTES: -.br -Lines beginning with '#' are considered comments. -.br -A special level must be explicitly aligned. The alignment of the dungeon -it is in only applies to non-special levels within that dungeon. -.SH AUTHOR -.PP -M. Stephenson (from the level compiler by Jean-Christophe Collet). -.SH "SEE ALSO" -.PP -lev_comp(6), nethack(6) -.SH BUGS -.PP -Probably infinite. -.SH COPYRIGHT -This file is Copyright (C) \*(Na and was last modified \*(Nd (version -\*(Nb:\*(Nr). -NetHack may be freely redistributed. See license for details. diff --git a/doc/dgn_comp.txt b/doc/dgn_comp.txt deleted file mode 100644 index 907a4f0a6..000000000 --- a/doc/dgn_comp.txt +++ /dev/null @@ -1,330 +0,0 @@ - - - -DGN_COMP(6) 1995 DGN_COMP(6) - - - -NAME - dgn_comp - NetHack dungeon compiler - -SYNOPSIS - dgn_comp [ file ] - - If no arguments are given, it reads standard input. - -DESCRIPTION - Dgn_comp is a dungeon compiler for NetHack version 3.2 and - higher. It takes a description file as an argument and pro- - duces a dungeon "script" that is to be loaded by NetHack at - runtime. - - The purpose of this tool is to provide NetHack administra- - tors and implementors with a convenient way to create a cus- - tom dungeon for the game, without having to recompile the - entire world. - -GRAMMAR - DUNGEON: name bonesmarker ( base , rand ) [ %age ] - - where name is the dungeon name, bonesmarker is a letter for - marking bones files, ( base , rand ) is the number of lev- - els, and %age is its percentage chance of being generated - (if absent, 100% chance). - - DESCRIPTION: tag - - where tag is currently one of HELLISH, MAZELIKE, or ROGUE- - LIKE. - - ALIGNMENT | LEVALIGN: [ lawful | neutral | chaotic | - unaligned ] - - gives the alignment of the dungeon/level (default is - unaligned). - - ENTRY: level - - the dungeon entry point. The dungeon connection attaches at - this level of the given dungeon. If the value of level is - negative, the entry level is calculated from the bottom of - the dungeon, with -1 being the last level. If this line is - not present in a dungeon description, the entry level - defaults to 1. - - PROTOFILE: name - - the prototypical name for dungeon level files in this - dungeon. For example, the PROTOFILE name for the dungeon - Vlad's Tower is tower. - - - -Dec Last change: 12 1 - - - - - - -DGN_COMP(6) 1995 DGN_COMP(6) - - - - LEVEL: name bonesmarker @ ( base , rand ) [ %age ] - - where name is the level name, bonesmarker is a letter for - marking bones files, ( base , rand ) is the location and - %age is the generation percentage, as above. - - RNDLEVEL: name bonesmarker @ ( base , rand ) [ %age ] - rndlevs - - where name is the level name, bonesmarker is a letter for - marking bones files, ( base , rand ) is the location, %age - is the generation percentage, as above, and rndlevs is the - number of similar levels available to choose from. - - CHAINLEVEL: name bonesmarker prev_name + ( base , rand ) [ - %age ] - - where name is the level name, bonesmarker is a letter for - marking bones files, prev_name is the name of a level - defined previously, ( base , rand ) is the offset from the - level being chained from, and %age is the generation percen- - tage. - - RNDCHAINLEVEL: name bonesmarker prev_name + ( base , rand ) - [ %age ] rndlevs - - where name is the level name, bonesmarker is a letter for - marking bones files, prev_name is the name of a level - defined previously, ( base , rand ) is the offset from the - level being chained from, %age is the generation percentage, - and rndlevs is the number of similar levels available to - choose from. - - LEVELDESC: type - - where type is the level type, (see DESCRIPTION, above). The - type is used to override any pre-set value used to describe - the entire dungeon, for this level only. - - BRANCH: name @ ( base , rand ) [ stair | no_up | no_down | - portal ] [ up | down ] - - where name is the name of the dungeon to branch to, and ( - base , rand ) is the location of the branch. The last two - optional arguments are the branch type and branch direction. - The type of a branch can be a two-way stair connection, a - one-way stair connection, or a magic portal. A one-way - stair is described by the types no_up and no_down which - specify which stair direction is missing. The default - branch type is stair. The direction for a stair can be - either up or down; direction is not applicable to portals. - The default direction is down. - - - -Dec Last change: 12 2 - - - - - - -DGN_COMP(6) 1995 DGN_COMP(6) - - - - CHAINBRANCH: name prev_name + ( base , rand ) [ stair | - no_up | no_down | portal ] [ up | down ] - - where name is the name of the dungeon to branch to, - prev_name is the name of a previously defined level and ( - base , rand ) is the offset from the level being chained - from. The optional branch type and direction are the same - as described above. - -GENERIC RULES - Each dungeon must have a unique bonesmarker , and each spe- - cial level must have a bonesmarker unique within its dungeon - (letters may be reused in different dungeons). If the - bonesmarker has the special value "none", no bones files - will be created for that level or dungeon. - - The value base may be in the range of 1 to MAXLEVEL (as - defined in global.h ). - - The value rand may be in the range of -1 to MAXLEVEL. - - If rand is -1 it will be replaced with the value - (num_dunlevs(dungeon) - base) during the load process (ie. - from here to the end of the dungeon). - - If rand is 0 the level is located absolutely at base. - - Branches don't have a probability. Dungeons do. If a - dungeon fails to be generated during load, all its levels - and branches are skipped. - - No level or branch may be chained from a level with a per- - centage generation probability. This is to prevent non- - resolution during the load. In addition, no branch may be - made from a dungeon with a percentage generation probability - for the same reason. - - As a general rule using the dungeon compiler: - - If a dungeon has a protofile name associated with it (eg. - tower) that file will be used. - - If a special level is present, it will override the above - rule and the appropriate file will be loaded. - - If neither of the above are present, the standard generator - will take over and make a "normal" level. - - A level alignment, if present, will override the alignment - of the dungeon that it exists within. - - - - - -Dec Last change: 12 3 - - - - - - -DGN_COMP(6) 1995 DGN_COMP(6) - - - -EXAMPLE - Here is the current syntax of the dungeon compiler's - "language": - - - # - # The dungeon description file for the "standard" original - # 3.0 NetHack. - # - DUNGEON: "The Dungeons of Doom" "D" (25, 5) - LEVEL: "rogue" "none" @ (15, 4) - LEVEL: "oracle" "none" @ (5, 7) - LEVEL: "bigroom" "B" @ (12, 3) 15 - LEVEL: "medusa" "none" @ (20, 5) - CHAINLEVEL: "castle" "medusa" + (1, 4) - CHAINBRANCH: "Hell" "castle" + (0, 0) no_down - BRANCH: "The Astral Plane" @ (1, 0) no_down up - - DUNGEON: "Hell" "H" (25, 5) - DESCRIPTION: mazelike - DESCRIPTION: hellish - BRANCH: "Vlad's Tower" @ (13, 5) up - LEVEL: "wizard" "none" @ (15, 10) - LEVEL: "fakewiz" "A" @ (5, 5) - LEVEL: "fakewiz" "B" @ (10, 5) - LEVEL: "fakewiz" "C" @ (15, 5) - LEVEL: "fakewiz" "D" @ (20, 5) - LEVEL: "fakewiz" "E" @ (25, 5) - - DUNGEON: "Vlad's Tower" "T" (3, 0) - PROTOFILE: "tower" - DESCRIPTION: mazelike - ENTRY: -1 - - DUNGEON: "The Astral Plane" "A" (1, 0) - DESCRIPTION: mazelike - PROTOFILE: "endgame" - - NOTES: - Lines beginning with '#' are considered comments. - A special level must be explicitly aligned. The alignment - of the dungeon it is in only applies to non-special levels - within that dungeon. - -AUTHOR - M. Stephenson (from the level compiler by Jean-Christophe - Collet). - -SEE ALSO - lev_comp(6), nethack(6) - - - - - -Dec Last change: 12 4 - - - - - - -DGN_COMP(6) 1995 DGN_COMP(6) - - - -BUGS - Probably infinite. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Dec Last change: 12 5 - - - diff --git a/include/dgn_file.h b/include/dgn_file.h index 9e20de9c8..442905cfb 100644 --- a/include/dgn_file.h +++ b/include/dgn_file.h @@ -18,22 +18,24 @@ struct couple { }; struct tmpdungeon { - char name[24], protoname[24]; + char *name, *protoname; struct couple lev; int flags, chance, levels, branches, entry_lev; /* entry level for this dungeon */ char boneschar; + int align; }; struct tmplevel { - char name[24]; + char *name; + char *chainlvl; struct couple lev; int chance, rndlevs, chain, flags; char boneschar; }; struct tmpbranch { - char name[24]; /* destination dungeon name */ + char *name; /* destination dungeon name */ struct couple lev; int chain; /* index into tmplevel array (chained branch)*/ int type; /* branch type (see below) */ diff --git a/include/extern.h b/include/extern.h index 694b2214a..3da1872a9 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1655,6 +1655,8 @@ E struct selectionvar *FDECL(l_selection_check, (lua_State *, int)); E int FDECL(l_selection_register, (lua_State *)); /* ### nhlua.c ### */ +E lua_State * NDECL(nhl_init); +E boolean FDECL(nhl_loadlua, (lua_State *, const char *)); E boolean FDECL(load_lua, (const char *)); E void FDECL(nhl_error, (lua_State *, const char *)); E void FDECL(lcheck_param_table, (lua_State *)); diff --git a/src/dungeon.c b/src/dungeon.c index 95c4a6cdb..09b0fdb7e 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -10,7 +10,7 @@ #include "sfproto.h" -#define DUNGEON_FILE "dungeon" +#define DUNGEON_FILE "dungeon.lua" #define X_START "x-strt" #define X_LOCATE "x-loca" @@ -765,21 +765,56 @@ struct level_map { { X_GOAL, &nemesis_level }, { "", (d_level *) 0 } }; +int +get_dgn_flags(L) +lua_State *L; +{ + int dgn_flags = 0; + const char *const flagstrs[] = { "town", "hellish", "mazelike", "roguelike", NULL}; + const int flagstrs2i[] = { TOWN, HELLISH, MAZELIKE, ROGUELIKE, 0 }; + + lua_getfield(L, -1, "flags"); + if (lua_type(L, -1) == LUA_TTABLE) { + int f, nflags; + lua_len(L, -1); + nflags = lua_tonumber(L, -1); + lua_pop(L, 1); + for (f = 0; f < nflags; f++) { + lua_pushinteger(L, f+1); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TSTRING) { + dgn_flags |= flagstrs2i[luaL_checkoption(L, -1, NULL, flagstrs)]; + lua_pop(L, 1); + } else + impossible("flags[%i] is not a string", f); + } + } else if (lua_type(L, -1) == LUA_TSTRING) { + dgn_flags |= flagstrs2i[luaL_checkoption(L, -1, NULL, flagstrs)]; + } else if (lua_type(L, -1) != LUA_TNIL) + impossible("flags is not an array or string"); + lua_pop(L, 1); + + return dgn_flags; +} + /* initialize the "dungeon" structs */ void init_dungeons() { - dlb *dgn_file; + const char *const dgnaligns[] = { "unaligned", "noalign", "lawful", "neutral", "chaotic", NULL}; + const int dgnaligns2i[] = { D_ALIGN_NONE, D_ALIGN_NONE, D_ALIGN_LAWFUL, D_ALIGN_NEUTRAL, D_ALIGN_CHAOTIC, D_ALIGN_NONE }; + lua_State *L; register int i, cl = 0, cb = 0; register s_level *x; struct proto_dungeon pd; struct level_map *lev_map; struct version_info vers_info; + (void) memset(&pd, 0, sizeof(struct proto_dungeon)); pd.n_levs = pd.n_brs = 0; - dgn_file = dlb_fopen(DUNGEON_FILE, RDBMODE); - if (!dgn_file) { + L = nhl_init(); + if (!nhl_loadlua(L, DUNGEON_FILE)) { char tbuf[BUFSZ]; Sprintf(tbuf, "Cannot open dungeon description - \"%s", DUNGEON_FILE); #ifdef DLBRSRC /* using a resource from the executable */ @@ -805,55 +840,186 @@ init_dungeons() panic1(tbuf); } - /* validate the data's version against the program's version */ - Fread((genericptr_t) &vers_info, sizeof vers_info, 1, dgn_file); - /* we'd better clear the screen now, since when error messages come from - * check_version() they will be printed using pline(), which doesn't - * mix with the raw messages that might be already on the screen - */ if (iflags.window_inited) clear_nhwindow(WIN_MAP); - if (!check_version(&vers_info, DUNGEON_FILE, TRUE, UTD_CHECKSIZES)) - panic("Dungeon description not valid."); + + g.sp_levchn = (s_level *) 0; + + lua_settop(L, 0); + + lua_getglobal(L, "dungeon"); + if (!lua_istable(L, -1)) + panic("dungeon is not a lua table"); + + lua_len(L, -1); + g.n_dgns = lua_tonumber(L, -1); + lua_pop(L, 1); + + pd.start = 0; + pd.n_levs = 0; + pd.n_brs = 0; /* * Read in each dungeon and transfer the results to the internal * dungeon arrays. */ - g.sp_levchn = (s_level *) 0; - Fread((genericptr_t) &g.n_dgns, sizeof(int), 1, dgn_file); + if (g.n_dgns >= MAXDUNGEON) panic("init_dungeons: too many dungeons"); - for (i = 0; i < g.n_dgns; i++) { - Fread((genericptr_t) &pd.tmpdungeon[i], sizeof(struct tmpdungeon), 1, - dgn_file); - if (!wizard && pd.tmpdungeon[i].chance - && (pd.tmpdungeon[i].chance <= rn2(100))) { - int j; + int tidx = lua_gettop(L); - /* skip over any levels or branches */ - for (j = 0; j < pd.tmpdungeon[i].levels; j++) - Fread((genericptr_t) &pd.tmplevel[cl], - sizeof(struct tmplevel), 1, dgn_file); + lua_pushnil(L); /* first key */ + i = 0; + while (lua_next(L, tidx) != 0) { + if (!lua_istable(L, -1)) + panic("dungeon[%i] is not a lua table", i); - for (j = 0; j < pd.tmpdungeon[i].branches; j++) - Fread((genericptr_t) &pd.tmpbranch[cb], - sizeof(struct tmpbranch), 1, dgn_file); + char *dgn_name = get_table_str(L, "name"); + char *dgn_bonetag = get_table_str_opt(L, "bonetag", ""); /* TODO: single char or "none" */ + char *dgn_protoname = get_table_str_opt(L, "protofile", ""); + int dgn_base = get_table_int(L, "base"); + int dgn_range = get_table_int_opt(L, "range", 0); + int dgn_align = dgnaligns2i[get_table_option(L, "alignment", "unaligned", dgnaligns)]; + int dgn_entry = get_table_int_opt(L, "entry", 0); + int dgn_chance = get_table_int_opt(L, "chance", 0); + int dgn_flags = get_dgn_flags(L); + + debugpline4("DUNGEON[%i]: %s, base=(%i,%i)", i, dgn_name, dgn_base, dgn_range); + + if (!wizard && dgn_chance && (dgn_chance <= rn2(100))) { + debugpline1("IGNORING %s", dgn_name); g.n_dgns--; - i--; + lua_pop(L, 1); /* pop the dungeon table */ continue; } - Strcpy(g.dungeons[i].dname, pd.tmpdungeon[i].name); - Strcpy(g.dungeons[i].proto, pd.tmpdungeon[i].protoname); - g.dungeons[i].boneid = pd.tmpdungeon[i].boneschar; + /* levels begin */ + lua_getfield(L, -1, "levels"); + if (lua_type(L, -1) == LUA_TTABLE) { + int f, nlevels; + lua_len(L, -1); + nlevels = lua_tonumber(L, -1); + pd.tmpdungeon[i].levels = nlevels; + lua_pop(L, 1); + for (f = 0; f < nlevels; f++) { + lua_pushinteger(L, f+1); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TTABLE) { + int bi; + char *lvl_name = get_table_str(L, "name"); + char *lvl_bonetag = get_table_str_opt(L, "bonetag", ""); + int lvl_base = get_table_int(L, "base"); + int lvl_range = get_table_int_opt(L, "range", 0); + int lvl_nlevels = get_table_int_opt(L, "nlevels", 0); + int lvl_chance = get_table_int_opt(L, "chance", 0); + char *lvl_chain = get_table_str_opt(L, "chainlevel", NULL); + int lvl_align = dgnaligns2i[get_table_option(L, "alignment", "unaligned", dgnaligns)]; + int lvl_flags = get_dgn_flags(L); + struct tmplevel *tmpl = &pd.tmplevel[pd.n_levs + f]; + debugpline4("LEVEL[%i]:%s,(%i,%i)", f, lvl_name, lvl_base, lvl_range); + tmpl->name = lvl_name; + tmpl->chainlvl = lvl_chain; + tmpl->lev.base = lvl_base; + tmpl->lev.rand = lvl_range; + tmpl->chance = lvl_chance; + tmpl->rndlevs = lvl_nlevels; + tmpl->flags = lvl_flags; + tmpl->chain = -1; + if (lvl_chain) { + debugpline1("CHAINLEVEL: %s", lvl_chain); + for (bi = 0; bi < pd.n_levs + f; bi++) { + debugpline2("checking(%i):%s", bi, pd.tmplevel[bi].name); + if (!strcmp(pd.tmplevel[bi].name, lvl_chain)) { + tmpl->chain = bi; + break; + } + } + if (tmpl->chain == -1) + panic("Could not chain level %s to %s", lvl_name, lvl_chain); + } + } else + panic("dungeon[%i].levels[%i] is not a hash", i, f); + lua_pop(L, 1); + } + pd.n_levs += nlevels; + if (pd.n_levs > LEV_LIMIT) + panic("init_dungeon: too many special levels"); + } else if (lua_type(L, -1) != LUA_TNIL) + panic("dungeon[%i].levels is not an array of hashes", i); + lua_pop(L, 1); + /* levels end */ - if (pd.tmpdungeon[i].lev.rand) - g.dungeons[i].num_dunlevs = (xchar) rn1(pd.tmpdungeon[i].lev.rand, - pd.tmpdungeon[i].lev.base); + /* branches begin */ + lua_getfield(L, -1, "branches"); + if (lua_type(L, -1) == LUA_TTABLE) { + int f, nbranches; + lua_len(L, -1); + nbranches = lua_tonumber(L, -1); + pd.tmpdungeon[i].branches = nbranches; + lua_pop(L, 1); + for (f = 0; f < nbranches; f++) { + lua_pushinteger(L, f+1); + lua_gettable(L, -2); + if (lua_type(L, -1) == LUA_TTABLE) { + int bi; + const char *const brdirstr[] = { "up", "down", NULL }; + const int brdirstr2i[] = { TRUE, FALSE, FALSE }; + const char *const brtypes[] = { "stair", "portal", "no_down", "no_up", NULL }; + const int brtypes2i[] = { TBR_STAIR, TBR_PORTAL, TBR_NO_DOWN, TBR_NO_UP, TBR_STAIR }; + char *br_name = get_table_str(L, "name"); + int br_base = get_table_int(L, "base"); + int br_range = get_table_int_opt(L, "range", 0); + int br_type = brtypes2i[get_table_option(L, "branchtype", "stair", brtypes)]; + int br_up = brdirstr2i[get_table_option(L, "direction", "down", brdirstr)]; + char *br_chain = get_table_str_opt(L, "chainlevel", NULL); + struct tmpbranch *tmpb = &pd.tmpbranch[pd.n_brs + f]; + + debugpline4("BRANCH[%i]:%s,(%i,%i)", f, br_name, br_base, br_range); + tmpb->name = br_name; + tmpb->lev.base = br_base; + tmpb->lev.rand = br_range; + tmpb->type = br_type; + tmpb->up = br_up; + tmpb->chain = -1; + if (br_chain) { + debugpline1("CHAINBRANCH:%s", br_chain); + for (bi = 0; bi < pd.n_levs + f - 1; bi++) + if (!strcmp(pd.tmplevel[bi].name, br_chain)) { + tmpb->chain = bi; + break; + } + } + } else + panic("dungeon[%i].branches[%i] is not a hash", i, f); + lua_pop(L, 1); + } + pd.n_brs += nbranches; + if (pd.n_brs > BRANCH_LIMIT) + panic("init_dungeon: too many branches"); + } else if (lua_type(L, -1) != LUA_TNIL) + panic("dungeon[%i].branches is not an array of hashes", i); + lua_pop(L, 1); + /* branches end */ + + pd.tmpdungeon[i].name = dgn_name; + pd.tmpdungeon[i].protoname = dgn_protoname; + pd.tmpdungeon[i].boneschar = *dgn_bonetag ? *dgn_bonetag : 0; + pd.tmpdungeon[i].lev.base = dgn_base; + pd.tmpdungeon[i].lev.rand = dgn_range; + pd.tmpdungeon[i].flags = dgn_flags; + pd.tmpdungeon[i].align = dgn_align; + pd.tmpdungeon[i].chance = dgn_chance; + pd.tmpdungeon[i].entry_lev = dgn_entry; + + Strcpy(g.dungeons[i].dname, dgn_name); /* FIXME: dname length */ + Strcpy(g.dungeons[i].proto, dgn_protoname); /* FIXME: proto length */ + g.dungeons[i].boneid = *dgn_bonetag ? *dgn_bonetag : 0; + + if (dgn_range) + g.dungeons[i].num_dunlevs = (xchar) rn1(dgn_range, dgn_base); else - g.dungeons[i].num_dunlevs = (xchar) pd.tmpdungeon[i].lev.base; + g.dungeons[i].num_dunlevs = (xchar) dgn_base; if (!i) { g.dungeons[i].ledger_start = 0; @@ -865,14 +1031,13 @@ init_dungeons() g.dungeons[i].dunlev_ureached = 0; } - g.dungeons[i].flags.hellish = !!(pd.tmpdungeon[i].flags & HELLISH); - g.dungeons[i].flags.maze_like = !!(pd.tmpdungeon[i].flags & MAZELIKE); - g.dungeons[i].flags.rogue_like = !!(pd.tmpdungeon[i].flags & ROGUELIKE); - g.dungeons[i].flags.align = - ((pd.tmpdungeon[i].flags & D_ALIGN_MASK) >> 4); + g.dungeons[i].flags.hellish = !!(dgn_flags & HELLISH); + g.dungeons[i].flags.maze_like = !!(dgn_flags & MAZELIKE); + g.dungeons[i].flags.rogue_like = !!(dgn_flags & ROGUELIKE); + g.dungeons[i].flags.align = dgn_align; + /* - * Set the entry level for this dungeon. The pd.tmpdungeon entry - * value means: + * Set the entry level for this dungeon. The entry value means: * < 0 from bottom (-1 == bottom level) * 0 default (top) * > 0 actual level (1 = top) @@ -880,13 +1045,13 @@ init_dungeons() * Note that the entry_lev field in the dungeon structure is * redundant. It is used only here and in print_dungeon(). */ - if (pd.tmpdungeon[i].entry_lev < 0) { + if (dgn_entry < 0) { g.dungeons[i].entry_lev = - g.dungeons[i].num_dunlevs + pd.tmpdungeon[i].entry_lev + 1; + g.dungeons[i].num_dunlevs + dgn_entry + 1; if (g.dungeons[i].entry_lev <= 0) g.dungeons[i].entry_lev = 1; - } else if (pd.tmpdungeon[i].entry_lev > 0) { - g.dungeons[i].entry_lev = pd.tmpdungeon[i].entry_lev; + } else if (dgn_entry > 0) { + g.dungeons[i].entry_lev = dgn_entry; if (g.dungeons[i].entry_lev > g.dungeons[i].num_dunlevs) g.dungeons[i].entry_lev = g.dungeons[i].num_dunlevs; } else { /* default */ @@ -928,23 +1093,14 @@ init_dungeons() - (g.dungeons[i].entry_lev - 1); } - /* this is redundant - it should have been flagged by dgn_comp */ if (g.dungeons[i].num_dunlevs > MAXLEVEL) g.dungeons[i].num_dunlevs = MAXLEVEL; - pd.start = pd.n_levs; /* save starting point */ - pd.n_levs += pd.tmpdungeon[i].levels; - if (pd.n_levs > LEV_LIMIT) - panic("init_dungeon: too many special levels"); - /* - * Read in the prototype special levels. Don't add generated - * special levels until they are all placed. - */ - for (; cl < pd.n_levs; cl++) { - Fread((genericptr_t) &pd.tmplevel[cl], sizeof(struct tmplevel), 1, - dgn_file); + + for (; cl < pd.n_levs; cl++) { init_level(i, cl, &pd); } + /* * Recursively place the generated levels for this dungeon. This * routine will attempt all possible combinations before giving @@ -957,18 +1113,18 @@ init_dungeons() fflush(stderr); getchar(); #endif + for (; pd.start < pd.n_levs; pd.start++) if (pd.final_lev[pd.start]) add_level(pd.final_lev[pd.start]); + /* levels handling end */ - pd.n_brs += pd.tmpdungeon[i].branches; - if (pd.n_brs > BRANCH_LIMIT) - panic("init_dungeon: too many branches"); - for (; cb < pd.n_brs; cb++) - Fread((genericptr_t) &pd.tmpbranch[cb], sizeof(struct tmpbranch), - 1, dgn_file); + lua_pop(L, 1); /* pop the dungeon table */ + i++; } - (void) dlb_fclose(dgn_file); + + lua_pop(L, 1); /* get rid of the dungeon global */ + debugpline2("init_dungeon lua DONE (n_levs=%i, n_brs=%i)", pd.n_levs, pd.n_brs); for (i = 0; i < 5; i++) g.tune[i] = 'A' + rn2(7); @@ -1028,6 +1184,8 @@ init_dungeons() so that it's hidden from '#wizwhere' feedback. */ } + lua_close(L); + #ifdef DEBUG dumpit(); #endif diff --git a/src/nhlua.c b/src/nhlua.c index 609b6ecf5..af9b939b7 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -503,7 +503,7 @@ const char *name; { int ret; - lua_getfield(L, 1, name); + lua_getfield(L, -1, name); ret = (int) luaL_checkinteger(L, -1); lua_pop(L, 1); return ret; @@ -518,7 +518,7 @@ int defval; { int ret = defval; - lua_getfield(L, 1, name); + lua_getfield(L, -1, name); if (!lua_isnil(L, -1)) { ret = (int) luaL_checkinteger(L, -1); } @@ -533,7 +533,7 @@ const char *name; { char *ret; - lua_getfield(L, 1, name); + lua_getfield(L, -1, name); ret = dupstr(luaL_checkstring(L, -1)); lua_pop(L, 1); return ret; @@ -549,10 +549,12 @@ char *defval; { const char *ret; - lua_getfield(L, 1, name); + lua_getfield(L, -1, name); ret = luaL_optstring(L, -1, defval); + if (ret) + ret = dupstr(ret); lua_pop(L, 1); - return ret ? dupstr(ret) : NULL; + return ret; } int @@ -563,7 +565,7 @@ const char *name; int ltyp; int ret = -1; - lua_getfield(L, 1, name); + lua_getfield(L, -1, name); ltyp = lua_type(L, -1); if (ltyp == LUA_TSTRING) { const char *const boolstr[] = { "true", "false", "yes", "no", NULL }; @@ -590,7 +592,7 @@ int defval; { int ret = defval; - lua_getfield(L, 1, name); + lua_getfield(L, -1, name); if (lua_type(L, -1) != LUA_TNIL) { lua_pop(L, 1); return get_table_boolean(L, name); @@ -608,7 +610,7 @@ const char *const opts[]; /* NULL-terminated list */ { int ret; - lua_getfield(L, 1, name); + lua_getfield(L, -1, name); ret = luaL_checkoption(L, -1, defval, opts); lua_pop(L, 1); return ret; @@ -842,11 +844,9 @@ give_up: return ret; } -boolean -load_lua(name) -const char *name; +lua_State * +nhl_init() { - boolean ret = TRUE; lua_State *L = luaL_newstate(); luaL_openlibs(L); @@ -867,6 +867,21 @@ const char *name; l_register_des(L); if (!nhl_loadlua(L, "nhlib.lua")) { + lua_close(L); + return (lua_State *) 0; + } + + return L; +} + +boolean +load_lua(name) +const char *name; +{ + boolean ret = TRUE; + lua_State *L = nhl_init(); + + if (!L) { ret = FALSE; goto give_up; } diff --git a/sys/share/dgn_comp.h b/sys/share/dgn_comp.h deleted file mode 100644 index 8f3ecfd64..000000000 --- a/sys/share/dgn_comp.h +++ /dev/null @@ -1,27 +0,0 @@ -#define INTEGER 257 -#define A_DUNGEON 258 -#define BRANCH 259 -#define CHBRANCH 260 -#define LEVEL 261 -#define RNDLEVEL 262 -#define CHLEVEL 263 -#define RNDCHLEVEL 264 -#define UP_OR_DOWN 265 -#define PROTOFILE 266 -#define DESCRIPTION 267 -#define DESCRIPTOR 268 -#define LEVELDESC 269 -#define ALIGNMENT 270 -#define LEVALIGN 271 -#define ENTRY 272 -#define STAIR 273 -#define NO_UP 274 -#define NO_DOWN 275 -#define PORTAL 276 -#define STRING 277 -typedef union -{ - int i; - char* str; -} YYSTYPE; -extern YYSTYPE yylval; diff --git a/sys/share/dgn_lex.c b/sys/share/dgn_lex.c deleted file mode 100644 index 752fcd55a..000000000 --- a/sys/share/dgn_lex.c +++ /dev/null @@ -1,2000 +0,0 @@ - -#line 3 "dgn_lex.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex via 'flex -S flexhack.skl' - * where flexhack.skl is a nethack-specific alternate skeleton derived - * from flex 2.6.0's skel.c (which in turn was generated from flex.skl). - * - * Support for C++, re-entrancy, and table serialization stripped out. - * NetHack's usage doesn't need them and we want to reduce the size and - * complexity of this skeleton as well as of the generated scanner code. - */ -#define FLEXHACK_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 0 - -#include "config.h" - -#include - -/* we don't care if actual types happen to have more bits than their names; - the tables will just take up more space, possibly slowing the parse; - still, allow config.h to override these via typedef+#define if desired */ -#ifndef FLEX_INT32_T -typedef int flex_int32_t; -#endif -#ifndef FLEX_INT16_T -typedef short int flex_int16_t; -#endif -#ifndef FLEX_UINT16_T -typedef unsigned short int flex_uint16_t; -#endif - -#define yyconst const - -#define FDECL_dummy /*empty*/ - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (uchar) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character - * in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern yy_size_t yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -#define YY_LESS_LINENO(n) -#define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg); \ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - -}; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart FDECL(FDECL_dummy, (FILE *input_file )); -void yy_switch_to_buffer FDECL(FDECL_dummy, (YY_BUFFER_STATE new_buffer )); -YY_BUFFER_STATE yy_create_buffer FDECL(FDECL_dummy, (FILE *file,int size )); -void yy_delete_buffer FDECL(FDECL_dummy, (YY_BUFFER_STATE b )); -void yy_flush_buffer FDECL(FDECL_dummy, (YY_BUFFER_STATE b )); -void yypush_buffer_state FDECL(FDECL_dummy, (YY_BUFFER_STATE new_buffer )); -void yypop_buffer_state FDECL(FDECL_dummy, (void )); - -static void yyensure_buffer_stack FDECL(FDECL_dummy, (void )); -static void yy_load_buffer_state FDECL(FDECL_dummy, (void )); -static void yy_init_buffer FDECL(FDECL_dummy, (YY_BUFFER_STATE b,FILE *file )); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE yy_scan_buffer FDECL(FDECL_dummy, (char *base,yy_size_t size )); -YY_BUFFER_STATE yy_scan_string FDECL(FDECL_dummy, (yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes FDECL(FDECL_dummy, (yyconst char *bytes,yy_size_t len )); - -void *yyalloc FDECL(FDECL_dummy, (yy_size_t )); -void *yyrealloc FDECL(FDECL_dummy, (void *,yy_size_t )); -void yyfree FDECL(FDECL_dummy, (void * )); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ) { \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ) { \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -typedef int yy_state_type; - -extern int yylineno; - -int yylineno = 1; - -extern char *yytext; -#ifdef yytext_ptr -#undef yytext_ptr -#endif -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state FDECL(FDECL_dummy, (void )); -static yy_state_type yy_try_NUL_trans FDECL(FDECL_dummy, (yy_state_type current_state )); -static int yy_get_next_buffer FDECL(FDECL_dummy, (void )); -static void yy_fatal_error FDECL(FDECL_dummy, (yyconst char msg[] )) NORETURN; - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 35 -#define YY_END_OF_BUFFER 36 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[196] = - { 0, - 0, 0, 36, 34, 33, 32, 34, 34, 29, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 33, - 32, 0, 30, 29, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 0, 31, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, - 4, 0, 25, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 6, 0, 0, 0, 5, 0, 0, 23, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 20, 0, 0, 0, 0, 8, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 22, - 15, 0, 21, 7, 19, 0, 0, 0, 0, 0, - 0, 13, 0, 0, 0, 26, 16, 0, 0, 12, - 0, 0, 0, 11, 9, 0, 17, 18, 0, 27, - 0, 28, 24, 10, 0 - - } ; - -static yyconst YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 6, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 7, 1, 1, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, - 1, 1, 1, 1, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 1, 1, 17, 18, 19, 20, 21, - 1, 22, 23, 24, 25, 26, 1, 1, 27, 1, - 1, 1, 1, 1, 28, 1, 29, 1, 30, 31, - - 32, 33, 34, 35, 36, 1, 37, 38, 39, 40, - 41, 42, 1, 43, 44, 45, 46, 1, 47, 1, - 1, 48, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst YY_CHAR yy_meta[49] = - { 0, - 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, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1 - } ; - -static yyconst flex_uint16_t yy_base[198] = - { 0, - 0, 213, 218, 220, 215, 220, 213, 210, 207, 196, - 190, 196, 37, 191, 197, 186, 188, 171, 164, 172, - 174, 173, 18, 160, 159, 154, 157, 11, 194, 194, - 220, 190, 220, 187, 177, 184, 183, 167, 170, 164, - 161, 166, 174, 155, 136, 144, 134, 132, 133, 26, - 135, 143, 147, 128, 145, 220, 170, 220, 158, 152, - 154, 159, 154, 145, 44, 142, 47, 124, 124, 125, - 129, 129, 115, 27, 121, 113, 111, 120, 115, 116, - 134, 142, 132, 128, 137, 121, 130, 129, 125, 129, - 131, 97, 220, 105, 94, 101, 95, 96, 94, 99, - - 105, 101, 89, 220, 95, 112, 114, 51, 112, 107, - 220, 110, 114, 111, 106, 96, 85, 76, 81, 82, - 88, 69, 220, 81, 76, 75, 220, 78, 99, 220, - 88, 97, 87, 88, 92, 93, 88, 91, 90, 71, - 65, 220, 62, 60, 57, 56, 220, 59, 54, 74, - 84, 65, 66, 220, 70, 65, 70, 60, 68, 220, - 220, 52, 220, 220, 220, 46, 50, 57, 61, 67, - 62, 220, 67, 64, 63, 220, 220, 42, 41, 220, - 61, 53, 49, 220, 220, 50, 220, 220, 51, 220, - 46, 220, 220, 220, 220, 62, 60 - - } ; - -static yyconst flex_int16_t yy_def[198] = - { 0, - 195, 1, 195, 195, 195, 195, 195, 196, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 197, 195, - 195, 196, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 197, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 0, 195, 195 - - } ; - -static yyconst flex_uint16_t yy_nxt[269] = - { 0, - 4, 5, 6, 7, 8, 4, 9, 10, 11, 12, - 13, 14, 4, 4, 4, 4, 15, 4, 4, 4, - 16, 17, 4, 4, 4, 4, 4, 4, 4, 18, - 19, 4, 4, 4, 20, 4, 4, 21, 22, 23, - 4, 24, 25, 26, 27, 28, 4, 4, 38, 49, - 55, 87, 56, 74, 75, 88, 90, 98, 50, 131, - 57, 39, 32, 91, 194, 193, 192, 132, 191, 190, - 189, 188, 99, 187, 186, 185, 184, 183, 182, 181, - 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, - 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, - - 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, - 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, - 140, 139, 138, 137, 136, 135, 134, 133, 130, 129, - 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, - 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, - 108, 107, 106, 105, 104, 103, 102, 101, 100, 97, - 96, 95, 94, 93, 92, 89, 86, 85, 84, 83, - 82, 81, 58, 80, 79, 78, 77, 76, 73, 72, - 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, - 61, 60, 59, 34, 33, 30, 58, 54, 53, 52, - - 51, 48, 47, 46, 45, 44, 43, 42, 41, 40, - 37, 36, 35, 34, 33, 31, 30, 195, 29, 3, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195 - } ; - -static yyconst flex_int16_t yy_chk[269] = - { 0, - 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, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 13, 23, - 28, 65, 28, 50, 50, 65, 67, 74, 23, 108, - 197, 13, 196, 67, 191, 189, 186, 108, 183, 182, - 181, 179, 74, 178, 175, 174, 173, 171, 170, 169, - 168, 167, 166, 162, 159, 158, 157, 156, 155, 153, - 152, 151, 150, 149, 148, 146, 145, 144, 143, 141, - - 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, - 129, 128, 126, 125, 124, 122, 121, 120, 119, 118, - 117, 116, 115, 114, 113, 112, 110, 109, 107, 106, - 105, 103, 102, 101, 100, 99, 98, 97, 96, 95, - 94, 92, 91, 90, 89, 88, 87, 86, 85, 84, - 83, 82, 81, 80, 79, 78, 77, 76, 75, 73, - 72, 71, 70, 69, 68, 66, 64, 63, 62, 61, - 60, 59, 57, 55, 54, 53, 52, 51, 49, 48, - 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, - 37, 36, 35, 34, 32, 30, 29, 27, 26, 25, - - 24, 22, 21, 20, 19, 18, 17, 16, 15, 14, - 12, 11, 10, 9, 8, 7, 5, 3, 2, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -/* NetHack 3.6 dgn_comp.l $NHDT-Date: 1522193682 2018/03/27 23:34:42 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.20 $ */ -/* Copyright (c) 1989 by Jean-Christophe Collet */ -/* Copyright (c) 1990 by M. Stephenson */ -/* NetHack may be freely redistributed. See license for details. */ - -#define DGN_COMP - -#include "config.h" -#include "dgn_comp.h" -#include "dgn_file.h" - -/* - * Most of these don't exist in flex, yywrap is macro and - * yyunput is properly declared in flex.skel. - */ -#if !defined(FLEX_SCANNER) && !defined(FLEXHACK_SCANNER) -int FDECL(yyback, (int *,int)); -int NDECL(yylook); -int NDECL(yyinput); -int NDECL(yywrap); -int NDECL(yylex); - /* Traditional lexes let yyunput() and yyoutput() default to int; - * newer ones may declare them as void since they don't return - * values. For even more fun, the lex supplied as part of the - * newer unbundled compiler for SunOS 4.x adds the void declarations - * (under __STDC__ or _cplusplus ifdefs -- otherwise they remain - * int) while the bundled lex and the one with the older unbundled - * compiler do not. To detect this, we need help from outside -- - * sys/unix/Makefile.utl. - * - * Digital UNIX is difficult and still has int in spite of all - * other signs. - */ -# if defined(NeXT) || defined(SVR4) || defined(_AIX32) -# define VOIDYYPUT -# endif -# if !defined(VOIDYYPUT) && defined(POSIX_TYPES) -# if !defined(BOS) && !defined(HISX) && !defined(_M_UNIX) && !defined(VMS) -# define VOIDYYPUT -# endif -# endif -# if !defined(VOIDYYPUT) && defined(WEIRD_LEX) -# if defined(SUNOS4) && defined(__STDC__) && (WEIRD_LEX > 1) -# define VOIDYYPUT -# endif -# endif -# if defined(VOIDYYPUT) && defined(__osf__) -# undef VOIDYYPUT -# endif -# ifdef VOIDYYPUT -void FDECL(yyunput, (int)); -void FDECL(yyoutput, (int)); -# else -int FDECL(yyunput, (int)); -int FDECL(yyoutput, (int)); -# endif - -#else /* !FLEX_SCANNER && !FLEXHACK_SCANNER */ -/* most recent flex allows suppressing yyunput() altogether when not needed */ -#define YY_NO_UNPUT -#define YY_NO_INPUT -#endif - -#if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER) -/* older flex wants this */ -#define YY_MALLOC_DECL genericptr_t FDECL(malloc, (size_t)); \ - genericptr_t FDECL(realloc, (genericptr_t, size_t)); -/* newer flex assumes so needs this in case it's been suppressed */ -YY_MALLOC_DECL -#endif - -void FDECL(init_yyin, (FILE *)); -void FDECL(init_yyout, (FILE *)); - -/* this doesn't always get put in dgn_comp.h - * (esp. when using older versions of bison) - */ -extern YYSTYPE yylval; - -int nh_line_number = 1; - -#define INITIAL 0 - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy FDECL(FDECL_dummy, (void )); -int yyget_debug FDECL(FDECL_dummy, (void )); -void yyset_debug FDECL(FDECL_dummy, (int debug_flag )); -YY_EXTRA_TYPE yyget_extra FDECL(FDECL_dummy, (void )); -void yyset_extra FDECL(FDECL_dummy, (YY_EXTRA_TYPE user_defined )); -FILE *yyget_in FDECL(FDECL_dummy, (void )); -void yyset_in FDECL(FDECL_dummy, (FILE * _in_str )); -FILE *yyget_out FDECL(FDECL_dummy, (void )); -void yyset_out FDECL(FDECL_dummy, (FILE * _out_str )); -yy_size_t yyget_leng FDECL(FDECL_dummy, (void )); -char *yyget_text FDECL(FDECL_dummy, (void )); -int yyget_lineno FDECL(FDECL_dummy, (void )); -void yyset_lineno FDECL(FDECL_dummy, (int _line_number )); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -extern int yywrap FDECL(FDECL_dummy, (void )); -#endif - -#ifndef YY_NO_UNPUT - -void yyunput FDECL(FDECL_dummy, (int c,char *buf_ptr )); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy FDECL(FDECL_dummy, (char *,yyconst char *,int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen FDECL(FDECL_dummy, (yyconst char * )); -#endif - -#ifndef YY_NO_INPUT - -static int input FDECL(FDECL_dummy, (void )); - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex FDECL(FDECL_dummy, (void)); - -#define YY_DECL int yylex () -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - if ( yyleng > 0 ) \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ - (yytext[yyleng - 1] == '\n'); \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_load_buffer_state( ); - } - - { - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 196 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 220 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -return(A_DUNGEON); - YY_BREAK -case 2: -YY_RULE_SETUP -{ yylval.i=1; return(UP_OR_DOWN); } - YY_BREAK -case 3: -YY_RULE_SETUP -{ yylval.i=0; return(UP_OR_DOWN); } - YY_BREAK -case 4: -YY_RULE_SETUP -return(ENTRY); - YY_BREAK -case 5: -YY_RULE_SETUP -return(STAIR); - YY_BREAK -case 6: -YY_RULE_SETUP -return(NO_UP); - YY_BREAK -case 7: -YY_RULE_SETUP -return(NO_DOWN); - YY_BREAK -case 8: -YY_RULE_SETUP -return(PORTAL); - YY_BREAK -case 9: -YY_RULE_SETUP -return(PROTOFILE); - YY_BREAK -case 10: -YY_RULE_SETUP -return(DESCRIPTION); - YY_BREAK -case 11: -YY_RULE_SETUP -return(LEVELDESC); - YY_BREAK -case 12: -YY_RULE_SETUP -return(ALIGNMENT); - YY_BREAK -case 13: -YY_RULE_SETUP -return(LEVALIGN); - YY_BREAK -case 14: -YY_RULE_SETUP -{ yylval.i=TOWN ; return(DESCRIPTOR); } - YY_BREAK -case 15: -YY_RULE_SETUP -{ yylval.i=HELLISH ; return(DESCRIPTOR); } - YY_BREAK -case 16: -YY_RULE_SETUP -{ yylval.i=MAZELIKE ; return(DESCRIPTOR); } - YY_BREAK -case 17: -YY_RULE_SETUP -{ yylval.i=ROGUELIKE ; return(DESCRIPTOR); } - YY_BREAK -case 18: -YY_RULE_SETUP -{ yylval.i=D_ALIGN_NONE ; return(DESCRIPTOR); } - YY_BREAK -case 19: -YY_RULE_SETUP -{ yylval.i=D_ALIGN_NONE ; return(DESCRIPTOR); } - YY_BREAK -case 20: -YY_RULE_SETUP -{ yylval.i=D_ALIGN_LAWFUL ; return(DESCRIPTOR); } - YY_BREAK -case 21: -YY_RULE_SETUP -{ yylval.i=D_ALIGN_NEUTRAL ; return(DESCRIPTOR); } - YY_BREAK -case 22: -YY_RULE_SETUP -{ yylval.i=D_ALIGN_CHAOTIC ; return(DESCRIPTOR); } - YY_BREAK -case 23: -YY_RULE_SETUP -return(BRANCH); - YY_BREAK -case 24: -YY_RULE_SETUP -return(CHBRANCH); - YY_BREAK -case 25: -YY_RULE_SETUP -return(LEVEL); - YY_BREAK -case 26: -YY_RULE_SETUP -return(RNDLEVEL); - YY_BREAK -case 27: -YY_RULE_SETUP -return(CHLEVEL); - YY_BREAK -case 28: -YY_RULE_SETUP -return(RNDCHLEVEL); - YY_BREAK -case 29: -YY_RULE_SETUP -{ yylval.i=atoi(yytext); return(INTEGER); } - YY_BREAK -case 30: -/* rule 30 can match eol */ -YY_RULE_SETUP -{ yytext[yyleng - 1] = '\0'; /* discard the trailing \" */ - yylval.str = dupstr(yytext + 1); /* skip the first \" */ - return STRING; } - YY_BREAK -case 31: -/* rule 31 can match eol */ -YY_RULE_SETUP -{ nh_line_number++; } - YY_BREAK -case 32: -/* rule 32 can match eol */ -YY_RULE_SETUP -{ nh_line_number++; } - YY_BREAK -case 33: -YY_RULE_SETUP -; /* skip trailing tabs & spaces */ - YY_BREAK -case 34: -YY_RULE_SETUP -{ return yytext[0]; } - YY_BREAK -case 35: -YY_RULE_SETUP -ECHO; - YY_BREAK -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer () -{ - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = (yytext_ptr); - yy_size_t number_to_move, i; - int ret_val; - - if ((yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1]) - YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed"); - - if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0) { - /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } else { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for (i = 0; i < number_to_move; ++i) - *(dest++) = *(source++); - - if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING) { - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - } else { - yy_size_t num_to_read; - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - /* [pr] This could probably be (b->yy_buf_size < number_to_move) - * since the allocated size is actually b->yy_buf_size + 2. - * The old code calculated num_to_read above (with same formula - * as is used below), then used (num_to_read <= 0) here, which - * got broken when num_to_read was changed to an unsigned type. */ - while (b->yy_buf_size <= number_to_move + 1) { - /* Not enough room in the buffer - grow it. */ - - int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) { - b->yy_buf_size += b->yy_buf_size / 4; - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if (! b->yy_ch_buf) - YY_FATAL_ERROR("fatal error - scanner input buffer overflow"); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - } - - num_to_read = b->yy_buf_size - number_to_move - 1; - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT((&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ((yy_n_chars) == 0) { - if (number_to_move == YY_MORE_ADJ) { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); - } else { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; - } - } else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) - > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) - yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if (! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf) - YY_FATAL_ERROR("out of dynamic memory in yy_get_next_buffer()"); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before EOB char was reached */ - -static yy_state_type yy_get_previous_state () -{ - yy_state_type yy_current_state; - char *yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); - - for (yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp) { - - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 196 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -static yy_state_type yy_try_NUL_trans (yy_current_state ) - yy_state_type yy_current_state; -{ - int yy_is_jam; - char *yy_cp = (yy_c_buf_p); - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 196 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 195); - - return yy_is_jam ? 0 : yy_current_state; -} - -#ifndef YY_NO_UNPUT - -void yyunput (c,yy_bp ) - int c; - char * yy_bp; -{ - char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - yy_size_t number_to_move = (yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#endif - -#ifndef YY_NO_INPUT -static int input () -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - return input(); - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(uchar *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - -void yyrestart (input_file ) - FILE * input_file; -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ -void yy_switch_to_buffer (new_buffer ) - YY_BUFFER_STATE new_buffer; -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void yy_load_buffer_state () -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ -YY_BUFFER_STATE yy_create_buffer (file,size ) - FILE * file; - int size; -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - if (!size) - size = YY_BUF_SIZE; - - b->yy_buf_size = (yy_size_t)size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ -void yy_delete_buffer (b ) - YY_BUFFER_STATE b; -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); - - yyfree((void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ -static void yy_init_buffer (b,file ) - YY_BUFFER_STATE b; - FILE * file; -{ - int oerrno = errno; - - yy_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ -void yy_flush_buffer (b ) - YY_BUFFER_STATE b; -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state (new_buffer ) - YY_BUFFER_STATE new_buffer; -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state () -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack () -{ - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ -#if 1 /* [PR] avoid C++-style comment; older C compilers choke on it */ - num_to_alloc = 2; /* also changed to match the comment... */ -#else - num_to_alloc = 1; // After all that talk, this was set to 1 anyways... -#endif - (yy_buffer_stack) = (struct yy_buffer_state**) - yyalloc(num_to_alloc * sizeof(struct yy_buffer_state*) ); - if (!(yy_buffer_stack)) - YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); - - (void) memset((yy_buffer_stack), 0, - num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1) { - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**) - yyrealloc((yy_buffer_stack),num_to_alloc * sizeof(struct yy_buffer_state*) ); - if (!(yy_buffer_stack)) - YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); - - /* zero only the new slots.*/ - (void) memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, - grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified - * character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (base,size ) - char * base; - yy_size_t size; -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() - * will scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yystr ) - yyconst char * yystr; -{ - - return yy_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to - * yylex() will scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a - * bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yybytes,_yybytes_len ) - yyconst char * yybytes; - yy_size_t _yybytes_len; -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - yy_size_t i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (msg ) - yyconst char* msg; -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg); \ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno () -{ - - return yylineno; -} - -/** Get the input stream. - * - */ -FILE *yyget_in () -{ - return yyin; -} - -/** Get the output stream. - * - */ -FILE *yyget_out () -{ - return yyout; -} - -/** Get the length of the current token. - * - */ -yy_size_t yyget_leng () -{ - return yyleng; -} - -/** Get the current token. - * - */ - -char *yyget_text () -{ - return yytext; -} - -/** Set the current line number. - * @param _line_number line number - * - */ -void yyset_lineno (_line_number ) - int _line_number; -{ - - yylineno = _line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in (_in_str ) - FILE * _in_str; -{ - yyin = _in_str ; -} - -void yyset_out (_out_str ) - FILE * _out_str; -{ - yyout = _out_str ; -} - -int yyget_debug () -{ - return yy_flex_debug; -} - -void yyset_debug (_bdebug ) - int _bdebug; -{ - yy_flex_debug = _bdebug ; -} - -static int yy_init_globals () -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy () -{ - - /* Pop the buffer stack, destroying each element. */ - while (YY_CURRENT_BUFFER) { - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner - * so the next time yylex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (s1,s2,n ) - char* s1; - yyconst char * s2; - int n; -{ - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (s ) - yyconst char * s; -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (size ) - yy_size_t size; -{ - - return (void *) malloc( size ); -} - -void *yyrealloc (ptr,size ) - void * ptr; - yy_size_t size; -{ - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (ptr ) - void * ptr; -{ - - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -/* routine to switch to another input file; needed for flex */ -void -init_yyin( input_f ) -FILE *input_f; -{ -#if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER) - if (yyin) - yyrestart(input_f); - else -#endif - yyin = input_f; -} - -/* analogous routine (for completeness) */ -void -init_yyout( output_f ) -FILE *output_f; -{ - yyout = output_f; -} - -/*dgn_comp.l*/ - diff --git a/sys/share/dgn_yacc.c b/sys/share/dgn_yacc.c deleted file mode 100644 index 742a7b1a7..000000000 --- a/sys/share/dgn_yacc.c +++ /dev/null @@ -1,1053 +0,0 @@ -#ifndef lint -/* static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; */ -/* static char nhsccsid[] = "@(#)yaccpar 1.9.0-nh (NetHack) 12/03/2015"; */ -#endif -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define YYSUBMINOR "0-nh" - -#define yyclearin (yychar=(-1)) -#define yyerrok (yyerrflag=0) -#define YYRECOVERING (yyerrflag!=0) -#define YYPREFIX "yy" -/* NetHack 3.6 dgn_comp.y $NHDT-Date: 1551901399 2019/03/06 19:43:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.15 $ */ -/* Copyright (c) 1989 by Jean-Christophe Collet */ -/* Copyright (c) 1990 by M. Stephenson */ -/* NetHack may be freely redistributed. See license for details. */ - -/* - * This file contains the Dungeon Compiler code - */ - -/* In case we're using bison in AIX. This definition must be - * placed before any other C-language construct in the file - * excluding comments and preprocessor directives (thanks IBM - * for this wonderful feature...). - * - * Note: some cpps barf on this 'undefined control' (#pragma). - * Addition of the leading space seems to prevent barfage for now, - * and AIX will still see the directive in its non-standard locale. - */ - -#ifdef _AIX - #pragma alloca /* keep leading space! */ -#endif - -#include "config.h" -#include "date.h" -#include "dgn_file.h" - -void FDECL(yyerror, (const char *)); -void FDECL(yywarning, (const char *)); -int NDECL(yylex); -int NDECL(yyparse); -int FDECL(getchain, (char *)); -int NDECL(check_dungeon); -int NDECL(check_branch); -int NDECL(check_level); -void NDECL(init_dungeon); -void NDECL(init_branch); -void NDECL(init_level); -void NDECL(output_dgn); - -#define Free(ptr) free((genericptr_t)ptr) - -#ifdef AMIGA -# undef printf -#ifndef LATTICE -# define memset(addr,val,len) setmem(addr,len,val) -#endif -#endif - -#define ERR (-1) - -static struct couple couple; -static struct tmpdungeon tmpdungeon[MAXDUNGEON]; -static struct tmplevel tmplevel[LEV_LIMIT]; -static struct tmpbranch tmpbranch[BRANCH_LIMIT]; - -static int in_dungeon = 0, n_dgns = -1, n_levs = -1, n_brs = -1; - -extern int fatal_error; -extern const char *fname; -extern FILE *yyin, *yyout; /* from dgn_lex.c */ - -typedef union -{ - int i; - char* str; -} YYSTYPE; -#define INTEGER 257 -#define A_DUNGEON 258 -#define BRANCH 259 -#define CHBRANCH 260 -#define LEVEL 261 -#define RNDLEVEL 262 -#define CHLEVEL 263 -#define RNDCHLEVEL 264 -#define UP_OR_DOWN 265 -#define PROTOFILE 266 -#define DESCRIPTION 267 -#define DESCRIPTOR 268 -#define LEVELDESC 269 -#define ALIGNMENT 270 -#define LEVALIGN 271 -#define ENTRY 272 -#define STAIR 273 -#define NO_UP 274 -#define NO_DOWN 275 -#define PORTAL 276 -#define STRING 277 -#define YYERRCODE 256 -short yylhs[] = { -1, - 0, 0, 5, 5, 6, 6, 6, 6, 7, 1, - 1, 8, 8, 8, 12, 13, 15, 15, 14, 10, - 10, 10, 10, 10, 16, 16, 17, 17, 18, 18, - 19, 19, 20, 20, 9, 9, 22, 23, 3, 3, - 3, 3, 3, 2, 2, 4, 21, 11, -}; -short yylen[] = { 2, - 0, 1, 1, 2, 1, 1, 1, 1, 6, 0, - 1, 1, 1, 1, 3, 1, 3, 3, 3, 1, - 1, 1, 1, 1, 6, 7, 7, 8, 3, 3, - 7, 8, 8, 9, 1, 1, 7, 8, 0, 1, - 1, 1, 1, 0, 1, 1, 5, 5, -}; -short yydefred[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 3, 5, 6, 7, 8, - 12, 13, 14, 16, 20, 21, 22, 23, 24, 35, - 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, - 0, 0, 19, 17, 29, 18, 30, 15, 46, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 11, 9, 0, 40, - 41, 42, 43, 0, 0, 0, 0, 0, 0, 0, - 0, 45, 37, 0, 27, 0, 0, 0, 0, 0, - 38, 28, 33, 0, 48, 47, 34, -}; -short yydgoto[] = { 14, - 78, 93, 84, 60, 15, 16, 17, 18, 19, 20, - 68, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 70, 30, 31, -}; -short yysindex[] = { -237, - -46, -45, -44, -39, -38, -30, -22, -21, -20, -19, - -18, -17, -16, 0, -237, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -262, -234, -233, -232, -230, -229, -228, -227, -217, - -216, -215, -214, -202, 0, -221, -7, -219, -221, -221, - -221, -221, 0, 0, 0, 0, 0, 0, 0, 19, - 20, 21, -2, -1, -212, -211, -190, -189, -188, -271, - 19, 20, 20, 27, 28, 29, 0, 0, 30, 0, - 0, 0, 0, -193, -271, -182, -180, 19, 19, -179, - -178, 0, 0, -193, 0, -177, -176, -175, 42, 43, - 0, 0, 0, -172, 0, 0, 0, -}; -short yyrindex[] = { 86, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 16, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 31, 1, 46, 0, 0, 0, 0, - 0, 0, 0, 31, 0, 61, 76, 0, 0, 0, - 0, 0, 0, 91, 0, 0, 0, -}; -short yygindex[] = { 0, - 0, -6, 4, -43, 0, 75, 0, 0, 0, 0, - -71, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -62, 0, 0, -}; -#define YYTABLESIZE 363 -short yytable[] = { 85, - 39, 80, 81, 82, 83, 63, 64, 65, 66, 86, - 87, 32, 33, 34, 46, 10, 97, 98, 35, 36, - 1, 2, 3, 4, 5, 6, 7, 37, 8, 9, - 44, 10, 11, 12, 13, 38, 39, 40, 41, 42, - 43, 44, 47, 48, 49, 25, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 61, 62, 67, 69, - 26, 72, 73, 71, 74, 75, 76, 77, 79, 88, - 89, 92, 90, 91, 95, 31, 96, 99, 100, 102, - 103, 104, 105, 106, 107, 1, 2, 101, 94, 45, - 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 0, 39, - 39, 39, 39, 10, 10, 10, 10, 10, 10, 10, - 0, 10, 10, 0, 10, 10, 10, 10, 44, 44, - 44, 44, 44, 44, 44, 0, 44, 44, 0, 44, - 44, 44, 44, 25, 25, 25, 25, 25, 25, 25, - 0, 25, 25, 0, 25, 25, 25, 25, 26, 26, - 26, 26, 26, 26, 26, 0, 26, 26, 0, 26, - 26, 26, 26, 31, 31, 31, 31, 31, 31, 31, - 0, 31, 31, 0, 31, 31, 31, 31, 32, 32, - 32, 32, 32, 32, 32, 0, 32, 32, 0, 32, - 32, 32, 32, -}; -short yycheck[] = { 71, - 0, 273, 274, 275, 276, 49, 50, 51, 52, 72, - 73, 58, 58, 58, 277, 0, 88, 89, 58, 58, - 258, 259, 260, 261, 262, 263, 264, 58, 266, 267, - 0, 269, 270, 271, 272, 58, 58, 58, 58, 58, - 58, 58, 277, 277, 277, 0, 277, 277, 277, 277, - 268, 268, 268, 268, 257, 277, 64, 277, 40, 40, - 0, 64, 64, 43, 277, 277, 257, 257, 257, 43, - 43, 265, 44, 44, 257, 0, 257, 257, 257, 257, - 257, 257, 41, 41, 257, 0, 0, 94, 85, 15, - 0, -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, -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, -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, -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, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 258, 259, - 260, 261, 262, 263, 264, 265, 266, 267, -1, 269, - 270, 271, 272, 258, 259, 260, 261, 262, 263, 264, - -1, 266, 267, -1, 269, 270, 271, 272, 258, 259, - 260, 261, 262, 263, 264, -1, 266, 267, -1, 269, - 270, 271, 272, 258, 259, 260, 261, 262, 263, 264, - -1, 266, 267, -1, 269, 270, 271, 272, 258, 259, - 260, 261, 262, 263, 264, -1, 266, 267, -1, 269, - 270, 271, 272, 258, 259, 260, 261, 262, 263, 264, - -1, 266, 267, -1, 269, 270, 271, 272, 258, 259, - 260, 261, 262, 263, 264, -1, 266, 267, -1, 269, - 270, 271, 272, -}; -#define YYFINAL 14 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 277 -#if YYDEBUG -char *yyname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'('","')'",0,"'+'","','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0, -"'@'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"INTEGER", -"A_DUNGEON","BRANCH","CHBRANCH","LEVEL","RNDLEVEL","CHLEVEL","RNDCHLEVEL", -"UP_OR_DOWN","PROTOFILE","DESCRIPTION","DESCRIPTOR","LEVELDESC","ALIGNMENT", -"LEVALIGN","ENTRY","STAIR","NO_UP","NO_DOWN","PORTAL","STRING", -}; -char *yyrule[] = { -"$accept : file", -"file :", -"file : dungeons", -"dungeons : dungeon", -"dungeons : dungeons dungeon", -"dungeon : dungeonline", -"dungeon : dungeondesc", -"dungeon : branches", -"dungeon : levels", -"dungeonline : A_DUNGEON ':' STRING bones_tag rcouple optional_int", -"optional_int :", -"optional_int : INTEGER", -"dungeondesc : entry", -"dungeondesc : descriptions", -"dungeondesc : prototype", -"entry : ENTRY ':' INTEGER", -"descriptions : desc", -"desc : DESCRIPTION ':' DESCRIPTOR", -"desc : ALIGNMENT ':' DESCRIPTOR", -"prototype : PROTOFILE ':' STRING", -"levels : level1", -"levels : level2", -"levels : levdesc", -"levels : chlevel1", -"levels : chlevel2", -"level1 : LEVEL ':' STRING bones_tag '@' acouple", -"level1 : RNDLEVEL ':' STRING bones_tag '@' acouple INTEGER", -"level2 : LEVEL ':' STRING bones_tag '@' acouple INTEGER", -"level2 : RNDLEVEL ':' STRING bones_tag '@' acouple INTEGER INTEGER", -"levdesc : LEVELDESC ':' DESCRIPTOR", -"levdesc : LEVALIGN ':' DESCRIPTOR", -"chlevel1 : CHLEVEL ':' STRING bones_tag STRING '+' rcouple", -"chlevel1 : RNDCHLEVEL ':' STRING bones_tag STRING '+' rcouple INTEGER", -"chlevel2 : CHLEVEL ':' STRING bones_tag STRING '+' rcouple INTEGER", -"chlevel2 : RNDCHLEVEL ':' STRING bones_tag STRING '+' rcouple INTEGER INTEGER", -"branches : branch", -"branches : chbranch", -"branch : BRANCH ':' STRING '@' acouple branch_type direction", -"chbranch : CHBRANCH ':' STRING STRING '+' rcouple branch_type direction", -"branch_type :", -"branch_type : STAIR", -"branch_type : NO_UP", -"branch_type : NO_DOWN", -"branch_type : PORTAL", -"direction :", -"direction : UP_OR_DOWN", -"bones_tag : STRING", -"acouple : '(' INTEGER ',' INTEGER ')'", -"rcouple : '(' INTEGER ',' INTEGER ')'", -}; -#endif -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 -#endif -#endif -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short yyss[YYSTACKSIZE]; -YYSTYPE yyvs[YYSTACKSIZE]; -#define yystacksize YYSTACKSIZE - -void -init_dungeon() -{ - if(++n_dgns > MAXDUNGEON) { - (void) fprintf(stderr, "FATAL - Too many dungeons (limit: %d).\n", - MAXDUNGEON); - (void) fprintf(stderr, "To increase the limit edit MAXDUNGEON in global.h\n"); - exit(EXIT_FAILURE); - } - - in_dungeon = 1; - tmpdungeon[n_dgns].lev.base = 0; - tmpdungeon[n_dgns].lev.rand = 0; - tmpdungeon[n_dgns].chance = 100; - Strcpy(tmpdungeon[n_dgns].name, ""); - Strcpy(tmpdungeon[n_dgns].protoname, ""); - tmpdungeon[n_dgns].flags = 0; - tmpdungeon[n_dgns].levels = 0; - tmpdungeon[n_dgns].branches = 0; - tmpdungeon[n_dgns].entry_lev = 0; -} - -void -init_level() -{ - if(++n_levs > LEV_LIMIT) { - - yyerror("FATAL - Too many special levels defined."); - exit(EXIT_FAILURE); - } - tmplevel[n_levs].lev.base = 0; - tmplevel[n_levs].lev.rand = 0; - tmplevel[n_levs].chance = 100; - tmplevel[n_levs].rndlevs = 0; - tmplevel[n_levs].flags = 0; - Strcpy(tmplevel[n_levs].name, ""); - tmplevel[n_levs].chain = -1; -} - -void -init_branch() -{ - if(++n_brs > BRANCH_LIMIT) { - - yyerror("FATAL - Too many special levels defined."); - exit(EXIT_FAILURE); - } - tmpbranch[n_brs].lev.base = 0; - tmpbranch[n_brs].lev.rand = 0; - Strcpy(tmpbranch[n_brs].name, ""); - tmpbranch[n_brs].chain = -1; -} - -int -getchain(s) - char *s; -{ - int i; - - if(strlen(s)) { - - for(i = n_levs - tmpdungeon[n_dgns].levels + 1; i <= n_levs; i++) - if(!strcmp(tmplevel[i].name, s)) return i; - - yyerror("Can't locate the specified chain level."); - return(-2); - } - return(-1); -} - -/* - * Consistancy checking routines: - * - * - A dungeon must have a unique name. - * - A dungeon must have a originating "branch" command - * (except, of course, for the first dungeon). - * - A dungeon must have a proper depth (at least (1, 0)). - */ - -int -check_dungeon() -{ - int i; - - for(i = 0; i < n_dgns; i++) - if(!strcmp(tmpdungeon[i].name, tmpdungeon[n_dgns].name)) { - yyerror("Duplicate dungeon name."); - return(0); - } - - if(n_dgns) - for(i = 0; i < n_brs - tmpdungeon[n_dgns].branches; i++) { - if(!strcmp(tmpbranch[i].name, tmpdungeon[n_dgns].name)) break; - - if(i >= n_brs - tmpdungeon[n_dgns].branches) { - yyerror("Dungeon cannot be reached."); - return(0); - } - } - - if(tmpdungeon[n_dgns].lev.base <= 0 || - tmpdungeon[n_dgns].lev.rand < 0) { - yyerror("Invalid dungeon depth specified."); - return(0); - } - return(1); /* OK */ -} - -/* - * - A level must have a unique level name. - * - If chained, the level used as reference for the chain - * must be in this dungeon, must be previously defined, and - * the level chained from must be "non-probabilistic" (ie. - * have a 100% chance of existing). - */ - -int -check_level() -{ - int i; - - if(!in_dungeon) { - yyerror("Level defined outside of dungeon."); - return(0); - } - - for(i = 0; i < n_levs; i++) - if(!strcmp(tmplevel[i].name, tmplevel[n_levs].name)) { - yyerror("Duplicate level name."); - return(0); - } - - if(tmplevel[i].chain == -2) { - yyerror("Invaild level chain reference."); - return(0); - } else if(tmplevel[i].chain != -1) { /* there is a chain */ - /* KMH -- tmplevel[tmpbranch[i].chain].chance was in error */ - if(tmplevel[tmplevel[i].chain].chance != 100) { - yyerror("Level cannot chain from a probabilistic level."); - return(0); - } else if(tmplevel[i].chain == n_levs) { - yyerror("A level cannot chain to itself!"); - return(0); - } - } - return(1); /* OK */ -} - -/* - * - A branch may not branch backwards - to avoid branch loops. - * - A branch name must be unique. - * (ie. You can only have one entry point to each dungeon). - * - If chained, the level used as reference for the chain - * must be in this dungeon, must be previously defined, and - * the level chained from must be "non-probabilistic" (ie. - * have a 100% chance of existing). - */ - -int -check_branch() -{ - int i; - - if(!in_dungeon) { - yyerror("Branch defined outside of dungeon."); - return(0); - } - - for(i = 0; i < n_dgns; i++) - if(!strcmp(tmpdungeon[i].name, tmpbranch[n_brs].name)) { - - yyerror("Reverse branching not allowed."); - return(0); - } - - if(tmpbranch[i].chain == -2) { - - yyerror("Invaild branch chain reference."); - return(0); - } else if(tmpbranch[i].chain != -1) { /* it is chained */ - - if(tmplevel[tmpbranch[i].chain].chance != 100) { - yyerror("Branch cannot chain from a probabilistic level."); - return(0); - } - } - return(1); /* OK */ -} - -/* - * Output the dungon definition into a file. - * - * The file will have the following format: - * - * [ nethack version ID ] - * [ number of dungeons ] - * [ first dungeon struct ] - * [ levels for the first dungeon ] - * ... - * [ branches for the first dungeon ] - * ... - * [ second dungeon struct ] - * ... - */ - -void -output_dgn() -{ - int nd, cl = 0, nl = 0, - cb = 0, nb = 0; - static struct version_info version_data = { - VERSION_NUMBER, VERSION_FEATURES, - VERSION_SANITY1, VERSION_SANITY2, VERSION_SANITY3 - }; - - if(++n_dgns <= 0) { - yyerror("FATAL - no dungeons were defined."); - exit(EXIT_FAILURE); - } - - if (fwrite((char *)&version_data, sizeof version_data, 1, yyout) != 1) { - yyerror("FATAL - output failure."); - exit(EXIT_FAILURE); - } - - (void) fwrite((char *)&n_dgns, sizeof(int), 1, yyout); - for (nd = 0; nd < n_dgns; nd++) { - (void) fwrite((char *)&tmpdungeon[nd], sizeof(struct tmpdungeon), - 1, yyout); - - nl += tmpdungeon[nd].levels; - for(; cl < nl; cl++) - (void) fwrite((char *)&tmplevel[cl], sizeof(struct tmplevel), - 1, yyout); - - nb += tmpdungeon[nd].branches; - for(; cb < nb; cb++) - (void) fwrite((char *)&tmpbranch[cb], sizeof(struct tmpbranch), - 1, yyout); - } - /* apparently necessary for Think C 5.x, otherwise harmless */ - (void) fflush(yyout); -} - -/*dgn_comp.y*/ -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -int -yyparse() -{ - register int yym, yyn, yystate; -#if YYDEBUG - register char *yys; - extern char *getenv(); - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) != 0 && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) != 0 && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; - goto yynewerror; -yynewerror: - yyerror("syntax error"); - goto yyerrlab; -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) != 0 && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 2: -{ - output_dgn(); - } -break; -case 9: -{ - init_dungeon(); - Strcpy(tmpdungeon[n_dgns].name, yyvsp[-3].str); - tmpdungeon[n_dgns].boneschar = (char)yyvsp[-2].i; - tmpdungeon[n_dgns].lev.base = couple.base; - tmpdungeon[n_dgns].lev.rand = couple.rand; - tmpdungeon[n_dgns].chance = yyvsp[0].i; - Free(yyvsp[-3].str); - } -break; -case 10: -{ - yyval.i = 0; - } -break; -case 11: -{ - yyval.i = yyvsp[0].i; - } -break; -case 15: -{ - tmpdungeon[n_dgns].entry_lev = yyvsp[0].i; - } -break; -case 17: -{ - if(yyvsp[0].i <= TOWN || yyvsp[0].i >= D_ALIGN_CHAOTIC) - yyerror("Illegal description - ignoring!"); - else - tmpdungeon[n_dgns].flags |= yyvsp[0].i ; - } -break; -case 18: -{ - if(yyvsp[0].i && yyvsp[0].i < D_ALIGN_CHAOTIC) - yyerror("Illegal alignment - ignoring!"); - else - tmpdungeon[n_dgns].flags |= yyvsp[0].i ; - } -break; -case 19: -{ - Strcpy(tmpdungeon[n_dgns].protoname, yyvsp[0].str); - Free(yyvsp[0].str); - } -break; -case 25: -{ - init_level(); - Strcpy(tmplevel[n_levs].name, yyvsp[-3].str); - tmplevel[n_levs].boneschar = (char)yyvsp[-2].i; - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmpdungeon[n_dgns].levels++; - Free(yyvsp[-3].str); - } -break; -case 26: -{ - init_level(); - Strcpy(tmplevel[n_levs].name, yyvsp[-4].str); - tmplevel[n_levs].boneschar = (char)yyvsp[-3].i; - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].rndlevs = yyvsp[0].i; - tmpdungeon[n_dgns].levels++; - Free(yyvsp[-4].str); - } -break; -case 27: -{ - init_level(); - Strcpy(tmplevel[n_levs].name, yyvsp[-4].str); - tmplevel[n_levs].boneschar = (char)yyvsp[-3].i; - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].chance = yyvsp[0].i; - tmpdungeon[n_dgns].levels++; - Free(yyvsp[-4].str); - } -break; -case 28: -{ - init_level(); - Strcpy(tmplevel[n_levs].name, yyvsp[-5].str); - tmplevel[n_levs].boneschar = (char)yyvsp[-4].i; - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].chance = yyvsp[-1].i; - tmplevel[n_levs].rndlevs = yyvsp[0].i; - tmpdungeon[n_dgns].levels++; - Free(yyvsp[-5].str); - } -break; -case 29: -{ - if(yyvsp[0].i >= D_ALIGN_CHAOTIC) - yyerror("Illegal description - ignoring!"); - else - tmplevel[n_levs].flags |= yyvsp[0].i ; - } -break; -case 30: -{ - if(yyvsp[0].i && yyvsp[0].i < D_ALIGN_CHAOTIC) - yyerror("Illegal alignment - ignoring!"); - else - tmplevel[n_levs].flags |= yyvsp[0].i ; - } -break; -case 31: -{ - init_level(); - Strcpy(tmplevel[n_levs].name, yyvsp[-4].str); - tmplevel[n_levs].boneschar = (char)yyvsp[-3].i; - tmplevel[n_levs].chain = getchain(yyvsp[-2].str); - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - if(!check_level()) n_levs--; - else tmpdungeon[n_dgns].levels++; - Free(yyvsp[-4].str); - Free(yyvsp[-2].str); - } -break; -case 32: -{ - init_level(); - Strcpy(tmplevel[n_levs].name, yyvsp[-5].str); - tmplevel[n_levs].boneschar = (char)yyvsp[-4].i; - tmplevel[n_levs].chain = getchain(yyvsp[-3].str); - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].rndlevs = yyvsp[0].i; - if(!check_level()) n_levs--; - else tmpdungeon[n_dgns].levels++; - Free(yyvsp[-5].str); - Free(yyvsp[-3].str); - } -break; -case 33: -{ - init_level(); - Strcpy(tmplevel[n_levs].name, yyvsp[-5].str); - tmplevel[n_levs].boneschar = (char)yyvsp[-4].i; - tmplevel[n_levs].chain = getchain(yyvsp[-3].str); - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].chance = yyvsp[0].i; - if(!check_level()) n_levs--; - else tmpdungeon[n_dgns].levels++; - Free(yyvsp[-5].str); - Free(yyvsp[-3].str); - } -break; -case 34: -{ - init_level(); - Strcpy(tmplevel[n_levs].name, yyvsp[-6].str); - tmplevel[n_levs].boneschar = (char)yyvsp[-5].i; - tmplevel[n_levs].chain = getchain(yyvsp[-4].str); - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].chance = yyvsp[-1].i; - tmplevel[n_levs].rndlevs = yyvsp[0].i; - if(!check_level()) n_levs--; - else tmpdungeon[n_dgns].levels++; - Free(yyvsp[-6].str); - Free(yyvsp[-4].str); - } -break; -case 37: -{ - init_branch(); - Strcpy(tmpbranch[n_brs].name, yyvsp[-4].str); - tmpbranch[n_brs].lev.base = couple.base; - tmpbranch[n_brs].lev.rand = couple.rand; - tmpbranch[n_brs].type = yyvsp[-1].i; - tmpbranch[n_brs].up = yyvsp[0].i; - if(!check_branch()) n_brs--; - else tmpdungeon[n_dgns].branches++; - Free(yyvsp[-4].str); - } -break; -case 38: -{ - init_branch(); - Strcpy(tmpbranch[n_brs].name, yyvsp[-5].str); - tmpbranch[n_brs].chain = getchain(yyvsp[-4].str); - tmpbranch[n_brs].lev.base = couple.base; - tmpbranch[n_brs].lev.rand = couple.rand; - tmpbranch[n_brs].type = yyvsp[-1].i; - tmpbranch[n_brs].up = yyvsp[0].i; - if(!check_branch()) n_brs--; - else tmpdungeon[n_dgns].branches++; - Free(yyvsp[-5].str); - Free(yyvsp[-4].str); - } -break; -case 39: -{ - yyval.i = TBR_STAIR; /* two way stair */ - } -break; -case 40: -{ - yyval.i = TBR_STAIR; /* two way stair */ - } -break; -case 41: -{ - yyval.i = TBR_NO_UP; /* no up staircase */ - } -break; -case 42: -{ - yyval.i = TBR_NO_DOWN; /* no down staircase */ - } -break; -case 43: -{ - yyval.i = TBR_PORTAL; /* portal connection */ - } -break; -case 44: -{ - yyval.i = 0; /* defaults to down */ - } -break; -case 45: -{ - yyval.i = yyvsp[0].i; - } -break; -case 46: -{ - char *p = yyvsp[0].str; - if (strlen(p) != 1) { - if (strcmp(p, "none") != 0) - yyerror("Bones marker must be a single char, or \"none\"!"); - *p = '\0'; - } - yyval.i = *p; - Free(p); - } -break; -case 47: -{ - if (yyvsp[-3].i < -MAXLEVEL || yyvsp[-3].i > MAXLEVEL) { - yyerror("Abs base out of dlevel range - zeroing!"); - couple.base = couple.rand = 0; - } else if (yyvsp[-1].i < -1 || - ((yyvsp[-3].i < 0) ? (MAXLEVEL + yyvsp[-3].i + yyvsp[-1].i + 1) > MAXLEVEL : - (yyvsp[-3].i + yyvsp[-1].i) > MAXLEVEL)) { - yyerror("Abs range out of dlevel range - zeroing!"); - couple.base = couple.rand = 0; - } else { - couple.base = yyvsp[-3].i; - couple.rand = yyvsp[-1].i; - } - } -break; -case 48: -{ - if (yyvsp[-3].i < -MAXLEVEL || yyvsp[-3].i > MAXLEVEL) { - yyerror("Rel base out of dlevel range - zeroing!"); - couple.base = couple.rand = 0; - } else { - couple.base = yyvsp[-3].i; - couple.rand = yyvsp[-1].i; - } - } -break; - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) != 0 && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yyssp, yystate); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} diff --git a/sys/unix/Makefile.dat b/sys/unix/Makefile.dat index 975978f92..153e4b74d 100644 --- a/sys/unix/Makefile.dat +++ b/sys/unix/Makefile.dat @@ -11,14 +11,11 @@ NHSROOT=.. VARDAT = bogusmon data engrave epitaph rumors quest.dat oracles options -all: $(VARDAT) spec_levs quest_levs dungeon +all: $(VARDAT) spec_levs quest_levs ../util/makedefs: (cd ../util ; $(MAKE) makedefs) -../util/dgn_comp: - (cd ../util ; $(MAKE) dgn_comp) - ../util/tile2x11: (cd ../util ; $(MAKE) tile2x11) @@ -129,12 +126,8 @@ spec_levs: quest_levs: touch quest_levs -dungeon: dungeon.def ../util/makedefs ../util/dgn_comp - ../util/makedefs -e - ../util/dgn_comp dungeon.pdf - spotless: - -rm -f spec_levs quest_levs *.lev $(VARDAT) dungeon dungeon.pdf + -rm -f spec_levs quest_levs *.lev $(VARDAT) -rm -f nhdat x11tiles beostiles pet_mark.xbm pilemark.xbm rip.xpm mapbg.xpm -rm -f rip.img GEM_RSC.RSC title.img nh16.img NetHack.ad -rm -f nhsplash.xpm nhtiles.bmp diff --git a/sys/unix/Makefile.doc b/sys/unix/Makefile.doc index a9683288a..2d2a2dd03 100644 --- a/sys/unix/Makefile.doc +++ b/sys/unix/Makefile.doc @@ -67,26 +67,23 @@ MANEXT = 6 # manual installation for most BSD-style systems GAMEMANCREATE = cat nethack.6 | $(NHGREP) > -DGNMANCREATE = cat dgn_comp.6 | $(NHGREP) > RCVRMANCREATE = cat recover.6 | $(NHGREP) > DLBMANCREATE = cat dlb.6 | $(NHGREP) > MDMANCREATE = cat makedefs.6 | $(NHGREP) > # manual installation for most SYSV-style systems # GAMEMANCREATE = cat nethack.6 | $(NHGREP) | nroff -man - > -# DGNMANCREATE = cat dgn_comp.6 | $(NHGREP) | nroff -man - > # RCVRMANCREATE = cat recover.6 | $(NHGREP) | nroff -man - > # DLBMANCREATE = cat dlb.6 | $(NHGREP) | nroff -man - > # MDMANCREATE = cat makedefs.6 | $(NHGREP) | nroff -man - > manpages: -$(GAMEMANCREATE) $(MANDIR)/$(GAME).$(MANEXT) - -$(DGNMANCREATE) $(MANDIR)/dgn_comp.$(MANEXT) -$(RCVRMANCREATE) $(MANDIR)/recover.$(MANEXT) -$(DLBMANCREATE) $(MANDIR)/dlb.$(MANEXT) -$(MDMANCREATE) $(MANDIR)/makedefs.$(MANEXT) # manual creation for distribution -DISTRIB = Guidebook.txt nethack.txt dgn_comp.txt recover.txt \ +DISTRIB = Guidebook.txt nethack.txt recover.txt \ dlb.txt makedefs.txt distrib: $(DISTRIB) @@ -97,8 +94,6 @@ Guidebook.txt : Guidebook.mn tmac.n tmac.nh MAN2TXT = $(NHGREP) | nroff -man - | $(COLCMD) nethack.txt : nethack.6 cat nethack.6 | $(MAN2TXT) > nethack.txt -dgn_comp.txt : dgn_comp.6 - cat dgn_comp.6 | $(MAN2TXT) > dgn_comp.txt recover.txt : recover.6 cat recover.6 | $(MAN2TXT) > recover.txt dlb.txt : dlb.6 diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 095a3e931..4c22ff244 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -491,7 +491,7 @@ CSOURCES = $(HACKCSRC) $(SYSCSRC) $(WINCSRC) $(CHAINSRC) $(GENCSRC) # all .h files except date.h, onames.h, pm.h, and vis_tab.h which would # cause dependency loops if run through "make depend" -# and dgn_comp.h, dgn_file.h, special level & dungeon files. +# and dgn_file.h, special level & dungeon files. # HACKINCL = align.h amiconf.h artifact.h artilist.h attrib.h beconf.h botl.h \ color.h config.h config1.h context.h coord.h decl.h def_os2.h \ @@ -505,7 +505,7 @@ HACKINCL = align.h amiconf.h artifact.h artilist.h attrib.h beconf.h botl.h \ wincurs.h winX.h winprocs.h wintype.h you.h youprop.h HSOURCES = $(HACKINCL) date.h onames.h pm.h vis_tab.h \ - dgn_comp.h dgn_file.h + dgn_file.h # the following .o's _must_ be made before any others (for makedefs) FIRSTOBJ = monst.o objects.o diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top index 6c0bb2a56..13ceb19bf 100644 --- a/sys/unix/Makefile.top +++ b/sys/unix/Makefile.top @@ -88,14 +88,14 @@ SPEC_LEVS = asmodeus.lua baalz.lua bigrm-*.lua castle.lua fakewiz?.lua \ QUEST_LEVS = ???-goal.lua ???-fil?.lua ???-loca.lua ???-strt.lua DATNODLB = $(VARDATND) license symbols -DATDLB = $(DATHELP) dungeon tribute $(SPEC_LEVS) $(QUEST_LEVS) $(VARDATD) +DATDLB = $(DATHELP) dungeon.lua tribute $(SPEC_LEVS) $(QUEST_LEVS) $(VARDATD) DAT = $(DATNODLB) $(DATDLB) $(GAME): ( cd lib/lua-5.3.5/src && make a && cp liblua.a ../../../src/ ) ( cd src ; $(MAKE) ) -all: $(GAME) recover Guidebook $(VARDAT) dungeon spec_levs check-dlb +all: $(GAME) recover Guidebook $(VARDAT) spec_levs check-dlb true; $(MOREALL) @echo "Done." @@ -133,14 +133,10 @@ options: $(GAME) quest.dat: $(GAME) ( cd dat ; $(MAKE) quest.dat ) -spec_levs: dungeon +spec_levs: ( cd dat ; $(MAKE) spec_levs ) ( cd dat ; $(MAKE) quest_levs ) -dungeon: $(GAME) - ( cd util ; $(MAKE) dgn_comp ) - ( cd dat ; $(MAKE) dungeon ) - nhtiles.bmp: $(GAME) ( cd dat ; $(MAKE) nhtiles.bmp ) @@ -237,7 +233,7 @@ dofiles-nodlb: $(CHGRP) $(GAMEGRP) $(DAT) ; \ chmod $(FILEPERM) $(DAT) ) -update: $(GAME) recover $(VARDAT) dungeon spec_levs +update: $(GAME) recover $(VARDAT) spec_levs # (don't yank the old version out from under people who're playing it) -mv $(INSTDIR)/$(GAME) $(INSTDIR)/$(GAME).old # quest.dat is also kept open and has the same problems over NFS @@ -256,7 +252,7 @@ update: $(GAME) recover $(VARDAT) dungeon spec_levs rootcheck: @true; $(ROOTCHECK) -install: rootcheck $(GAME) recover $(VARDAT) dungeon spec_levs +install: rootcheck $(GAME) recover $(VARDAT) spec_levs true; $(PREINSTALL) # set up the directories # not all mkdirs have -p; those that don't will create a -p directory diff --git a/sys/unix/Makefile.utl b/sys/unix/Makefile.utl index 5c7ae6c0b..64dccf570 100644 --- a/sys/unix/Makefile.utl +++ b/sys/unix/Makefile.utl @@ -186,7 +186,6 @@ HACK_H = ../src/hack.h-t # utility .c files MAKESRC = makedefs.c -DGNCOMPSRC = dgn_yacc.c dgn_lex.c dgn_main.c RECOVSRC = recover.c DLBSRC = dlb_main.c UTILSRCS = $(MAKESRC) panic.c $(DGNCOMPSRC) $(RECOVSRC) $(DLBSRC) @@ -205,9 +204,6 @@ OALLOC = $(OBJDIR)/alloc.o panic.o # object files for makedefs MAKEOBJS = makedefs.o $(OMONOBJ) -# object files for dungeon compiler -DGNCOMPOBJS = dgn_yacc.o dgn_lex.o dgn_main.o $(OALLOC) - # object files for recovery utility RECOVOBJS = recover.o @@ -267,35 +263,6 @@ lintdefs: panic.o: panic.c $(CONFIG_H) -# dependencies for dgn_comp -# -dgn_comp: $(DGNCOMPOBJS) - $(CC) $(LFLAGS) -o dgn_comp $(DGNCOMPOBJS) $(LIBS) - -dgn_yacc.o: dgn_yacc.c $(CONFIG_H) ../include/dgn_file.h ../include/date.h -dgn_main.o: dgn_main.c $(CONFIG_H) ../include/dlb.h - -# see dgn_comp.l for WEIRD_LEX discussion -dgn_lex.o: dgn_lex.c $(CONFIG_H) ../include/dgn_comp.h ../include/dgn_file.h - $(CC) -c $(CFLAGS) -DWEIRD_LEX=`egrep -c _cplusplus dgn_lex.c` dgn_lex.c - -# '$(YACC) -d' generates both $(YTABC) and $(YTABH) in one run -../include/dgn_comp.h: dgn_yacc.c - -dgn_yacc.c: dgn_comp.y - $(YACC) $(YACCDIST) -d dgn_comp.y - sed -e 's#"$(YTABC)"#"$@"#' -e 's#$(YTABC):#$@:#' $(YTABC) > $@ \ - && rm $(YTABC) - sed -e 's#"$(YTABH)"#"dgn_comp.h"#' $(YTABH) > ../include/dgn_comp.h \ - && rm $(YTABH) - -dgn_lex.c: dgn_comp.l - $(LEX) $(FLEXDIST) dgn_comp.l - sed -e 's#"$(LEXYYC)"#"$@"#' -e 's# *$$##' \ - -e 's#static void yyunput#void yyunput#' $(LEXYYC) > $@ \ - && rm $(LEXYYC) -# note: is basic RE substitute for - # with all of extern.h's functions to complain about, we drown in # 'defined but not used' without -u lintdgn: @@ -501,17 +468,7 @@ $(HACK_H): $(CONFIG_H) $(CONFIG_H): ../include/config.h @( cd ../src ; $(MAKE) $(CONFIG_H) ) -# 'make dist' => put generated lex and yacc sources into place for distribution SYSSHARE=../sys/share/ -$(SYSSHARE)dgn_lex.c: dgn_lex.c - cp dgn_lex.c $@ -$(SYSSHARE)dgn_yacc.c: dgn_yacc.c - cp dgn_yacc.c $@ -$(SYSSHARE)dgn_comp.h: ../include/dgn_comp.h - cp ../include/dgn_comp.h $@ - -dist: $(SYSSHARE)dgn_lex.c $(SYSSHARE)dgn_yacc.c $(SYSSHARE)dgn_comp.h - @echo 'pre-generated lex and yacc sources are in place in sys/share' tags: $(UTILSRCS) @ctags -tw $(UTILSRCS) @@ -520,9 +477,7 @@ clean: -rm -f *.o spotless: clean - -rm -f dgn_lex.c dgn_yacc.c - -rm -f ../include/dgn_comp.h -rm -f ../include/tile.h tiletxt.c - -rm -f makedefs dgn_comp recover dlb + -rm -f makedefs recover dlb -rm -f gif2txt txt2ppm tile2x11 tile2img.ttp xpm2img.ttp \ tilemap tileedit tile2bmp diff --git a/util/dgn_comp.l b/util/dgn_comp.l deleted file mode 100644 index 99c8527a1..000000000 --- a/util/dgn_comp.l +++ /dev/null @@ -1,144 +0,0 @@ -%{ -/* NetHack 3.6 dgn_comp.l $NHDT-Date: 1455415007 2016/02/14 01:56:47 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.13 $ */ -/* Copyright (c) 1989 by Jean-Christophe Collet */ -/* Copyright (c) 1990 by M. Stephenson */ -/* NetHack may be freely redistributed. See license for details. */ - -#define DGN_COMP - -#include "config.h" -#include "dgn_comp.h" -#include "dgn_file.h" - -/* - * Most of these don't exist in flex, yywrap is macro and - * yyunput is properly declared in flex.skel. - */ -#if !defined(FLEX_SCANNER) && !defined(FLEXHACK_SCANNER) -int FDECL(yyback, (int *,int)); -int NDECL(yylook); -int NDECL(yyinput); -int NDECL(yywrap); -int NDECL(yylex); - /* Traditional lexes let yyunput() and yyoutput() default to int; - * newer ones may declare them as void since they don't return - * values. For even more fun, the lex supplied as part of the - * newer unbundled compiler for SunOS 4.x adds the void declarations - * (under __STDC__ or _cplusplus ifdefs -- otherwise they remain - * int) while the bundled lex and the one with the older unbundled - * compiler do not. To detect this, we need help from outside -- - * sys/unix/Makefile.utl. - * - * Digital UNIX is difficult and still has int in spite of all - * other signs. - */ -# if defined(NeXT) || defined(SVR4) || defined(_AIX32) -# define VOIDYYPUT -# endif -# if !defined(VOIDYYPUT) && defined(POSIX_TYPES) -# if !defined(BOS) && !defined(HISX) && !defined(_M_UNIX) && !defined(VMS) -# define VOIDYYPUT -# endif -# endif -# if !defined(VOIDYYPUT) && defined(WEIRD_LEX) -# if defined(SUNOS4) && defined(__STDC__) && (WEIRD_LEX > 1) -# define VOIDYYPUT -# endif -# endif -# if defined(VOIDYYPUT) && defined(__osf__) -# undef VOIDYYPUT -# endif -# ifdef VOIDYYPUT -void FDECL(yyunput, (int)); -void FDECL(yyoutput, (int)); -# else -int FDECL(yyunput, (int)); -int FDECL(yyoutput, (int)); -# endif - -#else /* !FLEX_SCANNER && !FLEXHACK_SCANNER */ -/* most recent flex allows suppressing yyunput() altogether when not needed */ -#define YY_NO_UNPUT -#define YY_NO_INPUT -#endif - -#if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER) -/* older flex wants this */ -#define YY_MALLOC_DECL genericptr_t FDECL(malloc, (size_t)); \ - genericptr_t FDECL(realloc, (genericptr_t, size_t)); -/* newer flex assumes so needs this in case it's been suppressed */ -YY_MALLOC_DECL -#endif - -void FDECL(init_yyin, (FILE *)); -void FDECL(init_yyout, (FILE *)); - -/* this doesn't always get put in dgn_comp.h - * (esp. when using older versions of bison) - */ -extern YYSTYPE yylval; - -int nh_line_number = 1; - -%} -%% -DUNGEON return(A_DUNGEON); -up { yylval.i=1; return(UP_OR_DOWN); } -down { yylval.i=0; return(UP_OR_DOWN); } -ENTRY return(ENTRY); -stair return(STAIR); -no_up return(NO_UP); -no_down return(NO_DOWN); -portal return(PORTAL); -PROTOFILE return(PROTOFILE); -DESCRIPTION return(DESCRIPTION); -LEVELDESC return(LEVELDESC); -ALIGNMENT return(ALIGNMENT); -LEVALIGN return(LEVALIGN); -town { yylval.i=TOWN ; return(DESCRIPTOR); } -hellish { yylval.i=HELLISH ; return(DESCRIPTOR); } -mazelike { yylval.i=MAZELIKE ; return(DESCRIPTOR); } -roguelike { yylval.i=ROGUELIKE ; return(DESCRIPTOR); } -unaligned { yylval.i=D_ALIGN_NONE ; return(DESCRIPTOR); } -noalign { yylval.i=D_ALIGN_NONE ; return(DESCRIPTOR); } -lawful { yylval.i=D_ALIGN_LAWFUL ; return(DESCRIPTOR); } -neutral { yylval.i=D_ALIGN_NEUTRAL ; return(DESCRIPTOR); } -chaotic { yylval.i=D_ALIGN_CHAOTIC ; return(DESCRIPTOR); } -BRANCH return(BRANCH); -CHAINBRANCH return(CHBRANCH); -LEVEL return(LEVEL); -RNDLEVEL return(RNDLEVEL); -CHAINLEVEL return(CHLEVEL); -RNDCHLEVEL return(RNDCHLEVEL); -[-0-9]+ { yylval.i=atoi(yytext); return(INTEGER); } -\"[^"]*\" { yytext[yyleng - 1] = '\0'; /* discard the trailing \" */ - yylval.str = dupstr(yytext + 1); /* skip the first \" */ - return STRING; } -^#.*\n { nh_line_number++; } -\r?\n { nh_line_number++; } -[ \t]+ ; /* skip trailing tabs & spaces */ -. { return yytext[0]; } -%% - -/* routine to switch to another input file; needed for flex */ -void -init_yyin( input_f ) -FILE *input_f; -{ -#if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER) - if (yyin) - yyrestart(input_f); - else -#endif - yyin = input_f; -} - -/* analogous routine (for completeness) */ -void -init_yyout( output_f ) -FILE *output_f; -{ - yyout = output_f; -} - -/*dgn_comp.l*/ diff --git a/util/dgn_comp.y b/util/dgn_comp.y deleted file mode 100644 index a00ff7559..000000000 --- a/util/dgn_comp.y +++ /dev/null @@ -1,678 +0,0 @@ -%{ -/* NetHack 3.6 dgn_comp.y $NHDT-Date: 1432512785 2015/05/25 00:13:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */ -/* Copyright (c) 1989 by Jean-Christophe Collet */ -/* Copyright (c) 1990 by M. Stephenson */ -/* NetHack may be freely redistributed. See license for details. */ - -/* - * This file contains the Dungeon Compiler code - */ - -/* In case we're using bison in AIX. This definition must be - * placed before any other C-language construct in the file - * excluding comments and preprocessor directives (thanks IBM - * for this wonderful feature...). - * - * Note: some cpps barf on this 'undefined control' (#pragma). - * Addition of the leading space seems to prevent barfage for now, - * and AIX will still see the directive in its non-standard locale. - */ - -#ifdef _AIX - #pragma alloca /* keep leading space! */ -#endif - -#include "config.h" -#include "date.h" -#include "dgn_file.h" - -void FDECL(yyerror, (const char *)); -void FDECL(yywarning, (const char *)); -int NDECL(yylex); -int NDECL(yyparse); -int FDECL(getchain, (char *)); -int NDECL(check_dungeon); -int NDECL(check_branch); -int NDECL(check_level); -void NDECL(init_dungeon); -void NDECL(init_branch); -void NDECL(init_level); -void NDECL(output_dgn); - -#define Free(ptr) free((genericptr_t)ptr) - -#ifdef AMIGA -# undef printf -#ifndef LATTICE -# define memset(addr,val,len) setmem(addr,len,val) -#endif -#endif - -#define ERR (-1) - -static struct couple couple; -static struct tmpdungeon tmpdungeon[MAXDUNGEON]; -static struct tmplevel tmplevel[LEV_LIMIT]; -static struct tmpbranch tmpbranch[BRANCH_LIMIT]; - -static int in_dungeon = 0, n_dgns = -1, n_levs = -1, n_brs = -1; - -extern int fatal_error; -extern const char *fname; -extern FILE *yyin, *yyout; /* from dgn_lex.c */ - -%} - -%union -{ - int i; - char* str; -} - -%token INTEGER -%token A_DUNGEON BRANCH CHBRANCH LEVEL RNDLEVEL CHLEVEL RNDCHLEVEL -%token UP_OR_DOWN PROTOFILE DESCRIPTION DESCRIPTOR LEVELDESC -%token ALIGNMENT LEVALIGN ENTRY STAIR NO_UP NO_DOWN PORTAL -%token STRING -%type optional_int direction branch_type bones_tag -%start file - -%% -file : /* nothing */ - | dungeons - { - output_dgn(); - } - ; - -dungeons : dungeon - | dungeons dungeon - ; - -dungeon : dungeonline - | dungeondesc - | branches - | levels - ; - -dungeonline : A_DUNGEON ':' STRING bones_tag rcouple optional_int - { - init_dungeon(); - Strcpy(tmpdungeon[n_dgns].name, $3); - tmpdungeon[n_dgns].boneschar = (char)$4; - tmpdungeon[n_dgns].lev.base = couple.base; - tmpdungeon[n_dgns].lev.rand = couple.rand; - tmpdungeon[n_dgns].chance = $6; - Free($3); - } - ; - -optional_int : /* nothing */ - { - $$ = 0; - } - | INTEGER - { - $$ = $1; - } - ; - -dungeondesc : entry - | descriptions - | prototype - ; - -entry : ENTRY ':' INTEGER - { - tmpdungeon[n_dgns].entry_lev = $3; - } - ; - -descriptions : desc - ; - -desc : DESCRIPTION ':' DESCRIPTOR - { - if($3 <= TOWN || $3 >= D_ALIGN_CHAOTIC) - yyerror("Illegal description - ignoring!"); - else - tmpdungeon[n_dgns].flags |= $3 ; - } - | ALIGNMENT ':' DESCRIPTOR - { - if($3 && $3 < D_ALIGN_CHAOTIC) - yyerror("Illegal alignment - ignoring!"); - else - tmpdungeon[n_dgns].flags |= $3 ; - } - ; - -prototype : PROTOFILE ':' STRING - { - Strcpy(tmpdungeon[n_dgns].protoname, $3); - Free($3); - } - ; - -levels : level1 - | level2 - | levdesc - | chlevel1 - | chlevel2 - ; - -level1 : LEVEL ':' STRING bones_tag '@' acouple - { - init_level(); - Strcpy(tmplevel[n_levs].name, $3); - tmplevel[n_levs].boneschar = (char)$4; - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmpdungeon[n_dgns].levels++; - Free($3); - } - | RNDLEVEL ':' STRING bones_tag '@' acouple INTEGER - { - init_level(); - Strcpy(tmplevel[n_levs].name, $3); - tmplevel[n_levs].boneschar = (char)$4; - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].rndlevs = $7; - tmpdungeon[n_dgns].levels++; - Free($3); - } - ; - -level2 : LEVEL ':' STRING bones_tag '@' acouple INTEGER - { - init_level(); - Strcpy(tmplevel[n_levs].name, $3); - tmplevel[n_levs].boneschar = (char)$4; - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].chance = $7; - tmpdungeon[n_dgns].levels++; - Free($3); - } - | RNDLEVEL ':' STRING bones_tag '@' acouple INTEGER INTEGER - { - init_level(); - Strcpy(tmplevel[n_levs].name, $3); - tmplevel[n_levs].boneschar = (char)$4; - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].chance = $7; - tmplevel[n_levs].rndlevs = $8; - tmpdungeon[n_dgns].levels++; - Free($3); - } - ; - -levdesc : LEVELDESC ':' DESCRIPTOR - { - if($3 >= D_ALIGN_CHAOTIC) - yyerror("Illegal description - ignoring!"); - else - tmplevel[n_levs].flags |= $3 ; - } - | LEVALIGN ':' DESCRIPTOR - { - if($3 && $3 < D_ALIGN_CHAOTIC) - yyerror("Illegal alignment - ignoring!"); - else - tmplevel[n_levs].flags |= $3 ; - } - ; - -chlevel1 : CHLEVEL ':' STRING bones_tag STRING '+' rcouple - { - init_level(); - Strcpy(tmplevel[n_levs].name, $3); - tmplevel[n_levs].boneschar = (char)$4; - tmplevel[n_levs].chain = getchain($5); - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - if(!check_level()) n_levs--; - else tmpdungeon[n_dgns].levels++; - Free($3); - Free($5); - } - | RNDCHLEVEL ':' STRING bones_tag STRING '+' rcouple INTEGER - { - init_level(); - Strcpy(tmplevel[n_levs].name, $3); - tmplevel[n_levs].boneschar = (char)$4; - tmplevel[n_levs].chain = getchain($5); - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].rndlevs = $8; - if(!check_level()) n_levs--; - else tmpdungeon[n_dgns].levels++; - Free($3); - Free($5); - } - ; - -chlevel2 : CHLEVEL ':' STRING bones_tag STRING '+' rcouple INTEGER - { - init_level(); - Strcpy(tmplevel[n_levs].name, $3); - tmplevel[n_levs].boneschar = (char)$4; - tmplevel[n_levs].chain = getchain($5); - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].chance = $8; - if(!check_level()) n_levs--; - else tmpdungeon[n_dgns].levels++; - Free($3); - Free($5); - } - | RNDCHLEVEL ':' STRING bones_tag STRING '+' rcouple INTEGER INTEGER - { - init_level(); - Strcpy(tmplevel[n_levs].name, $3); - tmplevel[n_levs].boneschar = (char)$4; - tmplevel[n_levs].chain = getchain($5); - tmplevel[n_levs].lev.base = couple.base; - tmplevel[n_levs].lev.rand = couple.rand; - tmplevel[n_levs].chance = $8; - tmplevel[n_levs].rndlevs = $9; - if(!check_level()) n_levs--; - else tmpdungeon[n_dgns].levels++; - Free($3); - Free($5); - } - ; - -branches : branch - | chbranch - ; - -branch : BRANCH ':' STRING '@' acouple branch_type direction - { - init_branch(); - Strcpy(tmpbranch[n_brs].name, $3); - tmpbranch[n_brs].lev.base = couple.base; - tmpbranch[n_brs].lev.rand = couple.rand; - tmpbranch[n_brs].type = $6; - tmpbranch[n_brs].up = $7; - if(!check_branch()) n_brs--; - else tmpdungeon[n_dgns].branches++; - Free($3); - } - ; - -chbranch : CHBRANCH ':' STRING STRING '+' rcouple branch_type direction - { - init_branch(); - Strcpy(tmpbranch[n_brs].name, $3); - tmpbranch[n_brs].chain = getchain($4); - tmpbranch[n_brs].lev.base = couple.base; - tmpbranch[n_brs].lev.rand = couple.rand; - tmpbranch[n_brs].type = $7; - tmpbranch[n_brs].up = $8; - if(!check_branch()) n_brs--; - else tmpdungeon[n_dgns].branches++; - Free($3); - Free($4); - } - ; - -branch_type : /* nothing */ - { - $$ = TBR_STAIR; /* two way stair */ - } - | STAIR - { - $$ = TBR_STAIR; /* two way stair */ - } - | NO_UP - { - $$ = TBR_NO_UP; /* no up staircase */ - } - | NO_DOWN - { - $$ = TBR_NO_DOWN; /* no down staircase */ - } - | PORTAL - { - $$ = TBR_PORTAL; /* portal connection */ - } - ; - -direction : /* nothing */ - { - $$ = 0; /* defaults to down */ - } - | UP_OR_DOWN - { - $$ = $1; - } - ; - -bones_tag : STRING - { - char *p = $1; - if (strlen(p) != 1) { - if (strcmp(p, "none") != 0) - yyerror("Bones marker must be a single char, or \"none\"!"); - *p = '\0'; - } - $$ = *p; - Free(p); - } - ; - -/* - * acouple rules: - * - * (base, range) where: - * - * base is either a positive or negative integer with a value - * less than or equal to MAXLEVEL. - * base > 0 indicates the base level. - * base < 0 indicates reverse index (-1 == lowest level) - * - * range is the random component. - * if range is zero, there is no random component. - * if range is -1 the dungeon loader will randomize between - * the base and the end of the dungeon. - * during dungeon load, range is always *added* to the base, - * therefore range + base(converted) must not exceed MAXLEVEL. - */ -acouple : '(' INTEGER ',' INTEGER ')' - { - if ($2 < -MAXLEVEL || $2 > MAXLEVEL) { - yyerror("Abs base out of dlevel range - zeroing!"); - couple.base = couple.rand = 0; - } else if ($4 < -1 || - (($2 < 0) ? (MAXLEVEL + $2 + $4 + 1) > MAXLEVEL : - ($2 + $4) > MAXLEVEL)) { - yyerror("Abs range out of dlevel range - zeroing!"); - couple.base = couple.rand = 0; - } else { - couple.base = $2; - couple.rand = $4; - } - } - ; - -/* - * rcouple rules: - * - * (base, range) where: - * - * base is either a positive or negative integer with a value - * less than or equal to MAXLEVEL. - * base > 0 indicates a forward index. - * base < 0 indicates a reverse index. - * base == 0 indicates on the parent level. - * - * range is the random component. - * if range is zero, there is no random component. - * during dungeon load, range is always *added* to the base, - * range + base(converted) may be very large. The dungeon - * loader will then correct to "between here and the top/bottom". - * - * There is no practical way of specifying "between here and the - * nth / nth last level". - */ -rcouple : '(' INTEGER ',' INTEGER ')' - { - if ($2 < -MAXLEVEL || $2 > MAXLEVEL) { - yyerror("Rel base out of dlevel range - zeroing!"); - couple.base = couple.rand = 0; - } else { - couple.base = $2; - couple.rand = $4; - } - } - ; -%% - -void -init_dungeon() -{ - if(++n_dgns > MAXDUNGEON) { - (void) fprintf(stderr, "FATAL - Too many dungeons (limit: %d).\n", - MAXDUNGEON); - (void) fprintf(stderr, "To increase the limit edit MAXDUNGEON in global.h\n"); - exit(EXIT_FAILURE); - } - - in_dungeon = 1; - tmpdungeon[n_dgns].lev.base = 0; - tmpdungeon[n_dgns].lev.rand = 0; - tmpdungeon[n_dgns].chance = 100; - Strcpy(tmpdungeon[n_dgns].name, ""); - Strcpy(tmpdungeon[n_dgns].protoname, ""); - tmpdungeon[n_dgns].flags = 0; - tmpdungeon[n_dgns].levels = 0; - tmpdungeon[n_dgns].branches = 0; - tmpdungeon[n_dgns].entry_lev = 0; -} - -void -init_level() -{ - if(++n_levs > LEV_LIMIT) { - - yyerror("FATAL - Too many special levels defined."); - exit(EXIT_FAILURE); - } - tmplevel[n_levs].lev.base = 0; - tmplevel[n_levs].lev.rand = 0; - tmplevel[n_levs].chance = 100; - tmplevel[n_levs].rndlevs = 0; - tmplevel[n_levs].flags = 0; - Strcpy(tmplevel[n_levs].name, ""); - tmplevel[n_levs].chain = -1; -} - -void -init_branch() -{ - if(++n_brs > BRANCH_LIMIT) { - - yyerror("FATAL - Too many special levels defined."); - exit(EXIT_FAILURE); - } - tmpbranch[n_brs].lev.base = 0; - tmpbranch[n_brs].lev.rand = 0; - Strcpy(tmpbranch[n_brs].name, ""); - tmpbranch[n_brs].chain = -1; -} - -int -getchain(s) - char *s; -{ - int i; - - if(strlen(s)) { - - for(i = n_levs - tmpdungeon[n_dgns].levels + 1; i <= n_levs; i++) - if(!strcmp(tmplevel[i].name, s)) return i; - - yyerror("Can't locate the specified chain level."); - return(-2); - } - return(-1); -} - -/* - * Consistancy checking routines: - * - * - A dungeon must have a unique name. - * - A dungeon must have a originating "branch" command - * (except, of course, for the first dungeon). - * - A dungeon must have a proper depth (at least (1, 0)). - */ - -int -check_dungeon() -{ - int i; - - for(i = 0; i < n_dgns; i++) - if(!strcmp(tmpdungeon[i].name, tmpdungeon[n_dgns].name)) { - yyerror("Duplicate dungeon name."); - return(0); - } - - if(n_dgns) - for(i = 0; i < n_brs - tmpdungeon[n_dgns].branches; i++) { - if(!strcmp(tmpbranch[i].name, tmpdungeon[n_dgns].name)) break; - - if(i >= n_brs - tmpdungeon[n_dgns].branches) { - yyerror("Dungeon cannot be reached."); - return(0); - } - } - - if(tmpdungeon[n_dgns].lev.base <= 0 || - tmpdungeon[n_dgns].lev.rand < 0) { - yyerror("Invalid dungeon depth specified."); - return(0); - } - return(1); /* OK */ -} - -/* - * - A level must have a unique level name. - * - If chained, the level used as reference for the chain - * must be in this dungeon, must be previously defined, and - * the level chained from must be "non-probabilistic" (ie. - * have a 100% chance of existing). - */ - -int -check_level() -{ - int i; - - if(!in_dungeon) { - yyerror("Level defined outside of dungeon."); - return(0); - } - - for(i = 0; i < n_levs; i++) - if(!strcmp(tmplevel[i].name, tmplevel[n_levs].name)) { - yyerror("Duplicate level name."); - return(0); - } - - if(tmplevel[i].chain == -2) { - yyerror("Invaild level chain reference."); - return(0); - } else if(tmplevel[i].chain != -1) { /* there is a chain */ - /* KMH -- tmplevel[tmpbranch[i].chain].chance was in error */ - if(tmplevel[tmplevel[i].chain].chance != 100) { - yyerror("Level cannot chain from a probabilistic level."); - return(0); - } else if(tmplevel[i].chain == n_levs) { - yyerror("A level cannot chain to itself!"); - return(0); - } - } - return(1); /* OK */ -} - -/* - * - A branch may not branch backwards - to avoid branch loops. - * - A branch name must be unique. - * (ie. You can only have one entry point to each dungeon). - * - If chained, the level used as reference for the chain - * must be in this dungeon, must be previously defined, and - * the level chained from must be "non-probabilistic" (ie. - * have a 100% chance of existing). - */ - -int -check_branch() -{ - int i; - - if(!in_dungeon) { - yyerror("Branch defined outside of dungeon."); - return(0); - } - - for(i = 0; i < n_dgns; i++) - if(!strcmp(tmpdungeon[i].name, tmpbranch[n_brs].name)) { - - yyerror("Reverse branching not allowed."); - return(0); - } - - if(tmpbranch[i].chain == -2) { - - yyerror("Invaild branch chain reference."); - return(0); - } else if(tmpbranch[i].chain != -1) { /* it is chained */ - - if(tmplevel[tmpbranch[i].chain].chance != 100) { - yyerror("Branch cannot chain from a probabilistic level."); - return(0); - } - } - return(1); /* OK */ -} - -/* - * Output the dungon definition into a file. - * - * The file will have the following format: - * - * [ nethack version ID ] - * [ number of dungeons ] - * [ first dungeon struct ] - * [ levels for the first dungeon ] - * ... - * [ branches for the first dungeon ] - * ... - * [ second dungeon struct ] - * ... - */ - -void -output_dgn() -{ - int nd, cl = 0, nl = 0, - cb = 0, nb = 0; - static struct version_info version_data = { - VERSION_NUMBER, VERSION_FEATURES, - VERSION_SANITY1, VERSION_SANITY2, VERSION_SANITY3 - }; - - if(++n_dgns <= 0) { - yyerror("FATAL - no dungeons were defined."); - exit(EXIT_FAILURE); - } - - if (fwrite((char *)&version_data, sizeof version_data, 1, yyout) != 1) { - yyerror("FATAL - output failure."); - exit(EXIT_FAILURE); - } - - (void) fwrite((char *)&n_dgns, sizeof(int), 1, yyout); - for (nd = 0; nd < n_dgns; nd++) { - (void) fwrite((char *)&tmpdungeon[nd], sizeof(struct tmpdungeon), - 1, yyout); - - nl += tmpdungeon[nd].levels; - for(; cl < nl; cl++) - (void) fwrite((char *)&tmplevel[cl], sizeof(struct tmplevel), - 1, yyout); - - nb += tmpdungeon[nd].branches; - for(; cb < nb; cb++) - (void) fwrite((char *)&tmpbranch[cb], sizeof(struct tmpbranch), - 1, yyout); - } - /* apparently necessary for Think C 5.x, otherwise harmless */ - (void) fflush(yyout); -} - -/*dgn_comp.y*/ diff --git a/util/dgn_main.c b/util/dgn_main.c deleted file mode 100644 index e3e5e5939..000000000 --- a/util/dgn_main.c +++ /dev/null @@ -1,193 +0,0 @@ -/* NetHack 3.6 dgn_main.c $NHDT-Date: 1432512785 2015/05/25 00:13:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.11 $ */ -/* Copyright (c) 1989 by Jean-Christophe Collet */ -/* Copyright (c) 1990 by M. Stephenson */ -/* NetHack may be freely redistributed. See license for details. */ - -/* - * This file contains the main function for the parser - * and some useful functions needed by yacc - */ - -#include "config.h" -#include "dlb.h" - -/* Macintosh-specific code */ -#if defined(__APPLE__) && defined(__MACH__) -/* MacOS X has Unix-style files and processes */ -#undef MAC -#endif -#ifdef MAC -#if defined(__SC__) || defined(__MRC__) -#define MPWTOOL -#include -#else -/* put dungeon file in library location */ -#define PREFIX ":lib:" -#endif -#endif - -#ifndef MPWTOOL -#define SpinCursor(x) -#endif - -#define MAX_ERRORS 25 - -extern int NDECL(yyparse); -extern int nh_line_number; -const char *fname = "(stdin)"; -int fatal_error = 0; - -int FDECL(main, (int, char **)); -void FDECL(yyerror, (const char *)); -void FDECL(yywarning, (const char *)); -int NDECL(yywrap); -void FDECL(init_yyin, (FILE *)); -void FDECL(init_yyout, (FILE *)); - -#ifdef AZTEC_36 -FILE *FDECL(freopen, (char *, char *, FILE *)); -#endif -#define Fprintf (void) fprintf - -#if defined(__BORLANDC__) && !defined(_WIN32) -extern unsigned _stklen = STKSIZ; -#endif -int -main(argc, argv) -int argc; -char **argv; -{ - char infile[64], outfile[64], basename[64]; - FILE *fin, *fout; - int i, len; - boolean errors_encountered = FALSE; -#if defined(MAC) && (defined(THINK_C) || defined(__MWERKS__)) - char *mark; - static char *mac_argv[] = { "dgn_comp", /* dummy argv[0] */ - ":dat:dungeon.pdf" }; - - argc = SIZE(mac_argv); - argv = mac_argv; -#endif - - Strcpy(infile, "(stdin)"); - fin = stdin; - Strcpy(outfile, "(stdout)"); - fout = stdout; - - if (argc == 1) { /* Read standard input */ - init_yyin(fin); - init_yyout(fout); - (void) yyparse(); - if (fatal_error > 0) - errors_encountered = TRUE; - } else { /* Otherwise every argument is a filename */ - for (i = 1; i < argc; i++) { - fname = strcpy(infile, argv[i]); - /* the input file had better be a .pdf file */ - len = strlen(fname) - 4; /* length excluding suffix */ - if (len < 0 || strncmp(".pdf", fname + len, 4)) { - Fprintf(stderr, "Error - file name \"%s\" in wrong format.\n", - fname); - errors_encountered = TRUE; - continue; - } - -/* build output file name */ -#if defined(MAC) && (defined(THINK_C) || defined(__MWERKS__)) - /* extract basename from path to infile */ - mark = strrchr(infile, ':'); - strcpy(basename, mark ? mark + 1 : infile); - mark = strchr(basename, '.'); - if (mark) - *mark = '\0'; -#else -/* Use the whole name - strip off the last 3 or 4 chars. */ - -#ifdef VMS /* avoid possible interaction with logical name */ - len++; /* retain "." as trailing punctuation */ -#endif - (void) strncpy(basename, infile, len); - basename[len] = '\0'; -#endif - - outfile[0] = '\0'; -#ifdef PREFIX - (void) strcat(outfile, PREFIX); -#endif - (void) strcat(outfile, basename); - - fin = freopen(infile, "r", stdin); - if (!fin) { - Fprintf(stderr, "Can't open %s for input.\n", infile); - perror(infile); - errors_encountered = TRUE; - continue; - } - fout = freopen(outfile, WRBMODE, stdout); - if (!fout) { - Fprintf(stderr, "Can't open %s for output.\n", outfile); - perror(outfile); - errors_encountered = TRUE; - continue; - } - init_yyin(fin); - init_yyout(fout); - (void) yyparse(); - nh_line_number = 1; - if (fatal_error > 0) { - errors_encountered = TRUE; - fatal_error = 0; - } - } - } - if (fout && fclose(fout) < 0) { - Fprintf(stderr, "Can't finish output file."); - perror(outfile); - errors_encountered = TRUE; - } - exit(errors_encountered ? EXIT_FAILURE : EXIT_SUCCESS); - /*NOTREACHED*/ - return 0; -} - -/* - * Each time the parser detects an error, it uses this function. - * Here we take count of the errors. To continue farther than - * MAX_ERRORS wouldn't be reasonable. - */ - -void -yyerror(s) -const char *s; -{ - (void) fprintf(stderr, "%s : line %d : %s\n", fname, nh_line_number, s); - if (++fatal_error > MAX_ERRORS) { - (void) fprintf(stderr, "Too many errors, good bye!\n"); - exit(EXIT_FAILURE); - } -} - -/* - * Just display a warning (that is : a non fatal error) - */ - -void -yywarning(s) -const char *s; -{ - (void) fprintf(stderr, "%s : line %d : WARNING : %s\n", fname, - nh_line_number, s); -} - -int -yywrap() -{ - SpinCursor(3); /* Don't know if this is a good place to put it ? - Is it called for our grammar ? - Often enough ? - Too often ? -- h+ */ - return 1; -} - -/*dgn_main.c*/