public IReceiver <Msg> Next(Msg item) { // Skip valid tokens before the error which were used for local error recovery. if (validPrefixVerifier != null) { validPrefixVerifier = validPrefixVerifier.Next(item); if (validPrefixVerifier != null) { return(this); } } var error = new Msg(PredefinedTokens.Error, null, errorLocation); // TODO: Location? if (null != exit.CloneVerifier().ForceNext(error, item)) { ReportError(); return(exit.ForceNext(error, item)); } else if (grammar.IsBeacon(item.Id) && null != exit.CloneVerifier().ForceNext(item)) { ReportError(); return(exit.ForceNext(item)); } errorLocation += item.Location; errorHLocation += item.HLocation; collectedInput.Add(item); return(this); }
public Msg(int id, int token, object value, Loc location, HLoc hLocation = default(HLoc)) : base(token, value) { this.Id = id; this.Location = location; this.HLocation = hLocation; }
internal bool isAlternative; // to ensure that alternative in not child #endif // Leaf public SppfNode(int token, object value, Loc location, HLoc hLocation) { this.Id = token; this.Value = value; this.Location = location; #if DEBUG timestamp = timestampGen++; #endif }
private HLoc MakeHLoc() { var result = new HLoc( priorLine, priorColumn, cursor.MarkerLine, cursor.MarkerColumn - 1); return(result); }
private int PrepareCurrent() { int token; this.currentPosition += (cursor.Marker - cursor.Start); this.hLocation = MakeHLoc(); this.location = new Loc(document, priorPosition, currentPosition); object tokenValue; this.skipCurrentToken = false; // TODO: // 1) cursor.Action -> list of real actions. for each real action create MsgData // 2) in build time ensure that within one state // actions cannot produce same token // 3) each action can produce multiple tokens (optional by now, but in future can be useful) cursor.CurrentActionId = cursor.Actions[0]; token = termFactory(cursor, out tokenValue); if (token >= 0 && !skipCurrentToken) { int id = cursor.EnvelopeId; // TODO: Amb & Main tokens for envelope.Id Current = new Msg(id, token, tokenValue, location, hLocation); // Shrodinger's token if (cursor.ActionCount > 1) { MsgData data = Current; for (int i = 1; i != cursor.ActionCount; ++i) { cursor.CurrentActionId = cursor.Actions[i]; this.skipCurrentToken = false; token = termFactory(cursor, out tokenValue); if (!skipCurrentToken) { data.Next = new MsgData(token, tokenValue); data = data.Next; } } } } else { token = -1; } return(token); }
public HLoc SingleLineNLTerm(char[] buffer, int start, int length) { int expectedLine = (buffer[start + length - 2] - '0'); int expectedLastColumn = length; var result = new HLoc( expectedLine, 1, expectedLine, expectedLastColumn); Result.Add(result); return(result); }
public Msg CreateBranch(Production rule, ArraySlice <Msg> prefix, IStackLookback <Msg> stackLookback) { if (prefix.Count == 0) { return(GetDefault(rule.OutcomeToken, stackLookback)); } Loc location; HLoc hLocation; var array = prefix.Array; switch (prefix.Count) { case 0: location = Loc.Unknown; hLocation = HLoc.Unknown; break; case 1: location = prefix.Array[prefix.Offset].Location; hLocation = prefix.Array[prefix.Offset].HLocation; break; default: location = prefix.Array[prefix.Offset].Location + prefix.Array[prefix.Offset + prefix.Count - 1].Location; hLocation = prefix.Array[prefix.Offset].HLocation + prefix.Array[prefix.Offset + prefix.Count - 1].HLocation; break; } // Location for IParsing service this._resultLocation = location; this._resultHLocation = hLocation; if (rule.PatternTokens.Length > prefix.Count) { FillEpsilonSuffix(rule.Index, prefix.Count, prefix.Array, prefix.Offset + prefix.Count, stackLookback); } object value = grammarAction(rule.Index, prefix.Array, prefix.Offset, context, stackLookback); return(new Msg(rule.OutcomeToken, value, location, hLocation)); }
public IReceiver <Msg> Done() { Loc location; HLoc hLocation; if (!object.Equals(priorInput, default(Msg))) { location = priorInput.Location.GetEndLocation(); hLocation = priorInput.HLocation.GetEndLocation(); } else { location = Loc.Unknown; hLocation = new HLoc(1, 1, 1, 1); } var eoi = new Msg(PredefinedTokens.Eoi, null, location, hLocation); return(Next(eoi)); }
public HLoc MultiLineTerm(char[] buffer, int start, int length) { int prefix = "begin-".Length; int suffix = "end-".Length; int innerLineCount = (length - prefix - suffix - 2) / 2; int expectedFirstLine = (buffer[start + prefix] - '0'); int expectedFirstColumn = 1; int expectedLastLine = (buffer[start + length - 1] - '0'); int expectedLastColumn = suffix + 1; var result = new HLoc( expectedFirstLine, expectedFirstColumn, expectedLastLine, expectedLastColumn); Result.Add(result); return result; }
public HLoc MultiLineTerm(char[] buffer, int start, int length) { int prefix = "begin-".Length; int suffix = "end-".Length; int innerLineCount = (length - prefix - suffix - 2) / 2; int expectedFirstLine = (buffer[start + prefix] - '0'); int expectedFirstColumn = 1; int expectedLastLine = (buffer[start + length - 1] - '0'); int expectedLastColumn = suffix + 1; var result = new HLoc( expectedFirstLine, expectedFirstColumn, expectedLastLine, expectedLastColumn); Result.Add(result); return(result); }
public HLoc GetHiglightHLocation(List <Msg> source) { for (int i = 0; i != Count; ++i) { if (this[i] != i) { if (source[i].HLocation.IsUnknown) { break; } return(source[i].HLocation); } } var errorItems = source.Select(s => s.HLocation); if (source.Count > 1) { errorItems = errorItems.Skip(1); } return(HLoc.Sum(errorItems)); }
public GameObject ImportVcf(string filename, bool importFirstPerson, out Vdf vdf) { Vcf vcf = VcfParser.ParseVcf(filename); vdf = VdfParser.ParseVdf(vcf.VdfFilename); Vtf vtf = VtfParser.ParseVtf(vcf.VtfFilename); Car carObject = Object.Instantiate(_carPrefab); carObject.Configure(vdf, vcf); carObject.gameObject.name = vdf.Name + " (" + vcf.VariantName + ")"; foreach (VLoc vLoc in vdf.VLocs) { GameObject vlocGo = new GameObject("VLOC"); vlocGo.transform.parent = carObject.transform; vlocGo.transform.localRotation = Quaternion.LookRotation(vLoc.Forward, vLoc.Up); vlocGo.transform.localPosition = vLoc.Position; } GameObject chassis = new GameObject("Chassis"); chassis.transform.parent = carObject.transform; GameObject thirdPerson = new GameObject("ThirdPerson"); thirdPerson.transform.parent = chassis.transform; Transform[] weaponMountTransforms = new Transform[vdf.HLocs.Count]; for (int i = 0; i < vdf.HLocs.Count; ++i) { HLoc hloc = vdf.HLocs[i]; Transform mountPoint = new GameObject(hloc.Label).transform; mountPoint.parent = thirdPerson.transform; mountPoint.localRotation = Quaternion.LookRotation(hloc.Forward, hloc.Up); mountPoint.localPosition = hloc.Position; weaponMountTransforms[i] = mountPoint; } Dictionary <string, GameObject> partDict = new Dictionary <string, GameObject>(); for (int i = 0; i < vdf.PartsThirdPerson.Count; ++i) { GameObject healthObject = new GameObject("Health " + i); healthObject.transform.SetParent(thirdPerson.transform); ImportCarParts(partDict, healthObject, vtf, vdf.PartsThirdPerson[i], _noColliderPrefab, false, false, i); if (i != 0) { healthObject.SetActive(false); } } MeshFilter[] meshFilters = thirdPerson.GetComponentsInChildren <MeshFilter>(); Bounds bounds = new Bounds(); bounds.SetMinMax(Vector3.one * float.MaxValue, Vector3.one * float.MinValue); foreach (MeshFilter meshFilter in meshFilters) { Vector3 min = Vector3.Min(bounds.min, meshFilter.transform.position + meshFilter.sharedMesh.bounds.min) - thirdPerson.transform.position; Vector3 max = Vector3.Max(bounds.max, meshFilter.transform.position + meshFilter.sharedMesh.bounds.max) - thirdPerson.transform.position; bounds.SetMinMax(min, max); } GameObject chassisCollider = new GameObject("ChassisColliders"); chassisCollider.transform.parent = carObject.transform; ImportCarParts(partDict, chassisCollider, vtf, vdf.PartsThirdPerson[0], _carBodyPrefab, true); for (int i = 0; i < vcf.Weapons.Count; ++i) { VcfWeapon weapon = vcf.Weapons[i]; int mountPoint = weapon.MountPoint; HLoc hloc = vdf.HLocs[mountPoint]; weapon.RearFacing = hloc.FacingDirection == 2; SdfPart[] partsArray; switch (hloc.MeshType) { case HardpointMeshType.Top: partsArray = weapon.Gdf.TopParts; break; case HardpointMeshType.Side: partsArray = weapon.Gdf.SideParts; break; case HardpointMeshType.Inside: partsArray = weapon.Gdf.InsideParts; break; case HardpointMeshType.Turret: partsArray = weapon.Gdf.TurretParts; break; default: partsArray = null; break; } if (partsArray != null) { Transform weaponTransform = new GameObject(weapon.Gdf.Name).transform; weaponTransform.SetParent(weaponMountTransforms[i]); weaponTransform.localPosition = Vector3.zero; weaponTransform.localRotation = Quaternion.identity; ImportCarParts(partDict, weaponTransform.gameObject, vtf, partsArray, _noColliderPrefab, false); weapon.Transform = weaponTransform; // Disable depth test for 'inside' weapons, otherwise they are obscured. if (hloc.MeshType == HardpointMeshType.Inside) { MeshRenderer weaponRenderer = weaponTransform.GetComponentInChildren <MeshRenderer>(); if (weaponRenderer != null) { weaponRenderer.sharedMaterial.shader = Shader.Find("Custom/CutOutWithoutZ"); } } } else { weapon.Transform = chassis.transform; } } // Note: The following is probably how I76 does collision detection. Two large boxes that encapsulate the entire vehicle. // Right now this won't work with Open76's raycast suspension, so I'm leaving this off for now. Investigate in the future. //var innerBox = chassisCollider.AddComponent<BoxCollider>(); //innerBox.center = vdf.BoundsInner.center; //innerBox.size = vdf.BoundsInner.size; //var outerBox = chassisCollider.AddComponent<BoxCollider>(); //outerBox.center = vdf.BoundsOuter.center; //outerBox.size = vdf.BoundsOuter.size; RaySusp[] frontWheels = null; if (vcf.FrontWheelDef != null) { frontWheels = CreateWheelPair(partDict, "Front", 0, carObject.gameObject, vdf, vtf, vcf.FrontWheelDef); carObject.Movement.FrontWheels = frontWheels; } if (vcf.MidWheelDef != null) { CreateWheelPair(partDict, "Mid", 2, carObject.gameObject, vdf, vtf, vcf.MidWheelDef); } RaySusp[] rearWheels = null; if (vcf.BackWheelDef != null) { rearWheels = CreateWheelPair(partDict, "Back", 4, carObject.gameObject, vdf, vtf, vcf.BackWheelDef); carObject.Movement.RearWheels = rearWheels; } if (importFirstPerson) { GameObject firstPerson = new GameObject("FirstPerson"); firstPerson.transform.parent = chassis.transform; ImportCarParts(partDict, firstPerson, vtf, vdf.PartsFirstPerson, _noColliderPrefab, false, true, 0, LayerMask.NameToLayer("FirstPerson")); carObject.InitPanels(); firstPerson.SetActive(false); } carObject.Movement.Initialise(chassis.transform, frontWheels, rearWheels); return(carObject.gameObject); }
public Msg(int token, object value, Loc location, HLoc hLocation = default(HLoc)) : this(token, token, value, location, hLocation) { }
public SyntaxException(Loc location, HLoc hLocation, string message) { this.location = location; this.hLocation = hLocation; this.message = message; }
public SyntaxException(Loc location, HLoc hLocation, string message) { this.location = location; this.hLocation = hLocation; this.message = message; }
public HLoc SingleLineNLTerm(char[] buffer, int start, int length) { int expectedLine = (buffer[start + length - 2] - '0'); int expectedLastColumn = length; var result = new HLoc( expectedLine, 1, expectedLine, expectedLastColumn); Result.Add(result); return result; }