コード例 #1
0
        protected override IParseResult TryGetTokenWithoutNullCheck(IStringStream inputStream, out IToken token)
        {
            token = null;

            if (EnforceCharacterRangeSeparatorEscaping && IsCharacterRangeSeparator(inputStream))
            {
                return(new FailureParseResult(inputStream.CurrentPosition, RegSeedErrorType.InvalidRange));
            }

            var rangeResult = _primitiveParser.TryParseCharacterRange(inputStream);

            if (rangeResult.IsSuccess)
            {
                var rangeTokenLength = (int)(inputStream.CurrentPosition - _initialStreamPosition);
                token = new CharacterRangeToken(rangeResult.Value, inputStream.CurrentPosition, rangeTokenLength);
                return(new SuccessParseResult());
            }

            if (!rangeResult.IsSuccess && rangeResult.ErrorType != RegSeedErrorType.None)
            {
                return(rangeResult);
            }

            var characterResult = _primitiveParser.TryParseCharacter(inputStream);

            if (!characterResult.IsSuccess)
            {
                return(characterResult);
            }

            var characterTokenLength = (int)(inputStream.CurrentPosition - _initialStreamPosition);

            token = new CharacterToken(characterResult.Value, inputStream.CurrentPosition, characterTokenLength);
            return(new SuccessParseResult());
        }
コード例 #2
0
ファイル: LexerTest.cs プロジェクト: todor-dk/IronSmalltalk
        public void Test_3_5_7_Characters_B()
        {
            // Scaled decimals
            Scanner lexer = this.GetLexer("$");
            object  obj   = lexer.GetToken();

            Assert.IsInstanceOfType(obj, typeof(CharacterToken));
            CharacterToken token = (CharacterToken)obj;

            Assert.IsFalse(token.IsValid);
            Assert.AreEqual("Missing character. Hit EOF.", token.ScanError);
            Assert.AreEqual(0, token.StartPosition.Position);
            Assert.AreEqual(1, token.StopPosition.Position);
        }
コード例 #3
0
        // http://www.w3.org/TR/html5/syntax.html#insert-a-character
        public INode InsertCharacter(CharacterToken token, IDocument doc)
        {
            //TODO - make sure the steps conform with the specs in the link above.

            //1. Let data be the characters passed to the algorithm, or, if no characters were explicitly
            //   specified, the character of the character token being processed.

            //2. Let the adjusted insertion location be the appropriate place for inserting a node.
            InsertionLocation adjustedInsertionLocation = GetAppropriatePlaceForInsertingANode();

            //3. If the adjusted insertion location is in a Document node, then abort these steps.
            //   NOTE: The DOM will not let Document nodes have Text node children, so they are dropped on the floor.
            if (adjustedInsertionLocation.Parent == doc)
            {
                return null;
            }

            //4. If there is a Text node immediately before the adjusted insertion location, then append data to
            //   that Text node's data.
            //   Otherwise, create a new Text node whose data is data and whose ownerDocument is the same as that
            //   of the element in which the adjusted insertion location finds itself, and insert the newly created
            //   node at the adjusted insertion location.
            IText prevTextNode = null;
            if (adjustedInsertionLocation.Child != null)
            {
                if (!adjustedInsertionLocation.InsertBefore)
                {
                    prevTextNode = adjustedInsertionLocation.Child as IText;
                }
                else{
                    prevTextNode = adjustedInsertionLocation.Child.previousSibling as IText;
                }
            } else
            {
                prevTextNode = adjustedInsertionLocation.Parent.lastChild as IText;
            }

            if (prevTextNode != null)
            {
                prevTextNode.appendData(token.Character.ToString());
                return prevTextNode;
            } else
            {
                INode element = HtmlElementFactory.Instance.CreateTextNode(token.Character.ToString(),
                                    adjustedInsertionLocation.Parent.ownerDocument);
                adjustedInsertionLocation.Parent.appendChild(element);
                return element;
            }
        }
コード例 #4
0
ファイル: LexerTest.cs プロジェクト: todor-dk/IronSmalltalk
        public void Test_3_5_7_Characters_A()
        {
            // Scaled decimals
            Scanner lexer = this.GetLexer("$A");
            object  obj   = lexer.GetToken();

            Assert.IsInstanceOfType(obj, typeof(CharacterToken));
            CharacterToken token = (CharacterToken)obj;

            Assert.IsTrue(token.IsValid);
            Assert.IsNull(token.ScanError);
            Assert.AreEqual(0, token.StartPosition.Position);
            Assert.AreEqual(1, token.StopPosition.Position);
            Assert.AreEqual('A', token.Value);

            // Should be the last one
            obj = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(EofToken));

            lexer = this.GetLexer("$Ü");
            obj   = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(CharacterToken));
            token = (CharacterToken)obj;
            Assert.IsTrue(token.IsValid);
            Assert.IsNull(token.ScanError);
            Assert.AreEqual(0, token.StartPosition.Position);
            Assert.AreEqual(1, token.StopPosition.Position);
            Assert.AreEqual('Ü', token.Value);

            // Should be the last one
            obj = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(EofToken));

            lexer = this.GetLexer("$ ");
            obj   = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(CharacterToken));
            token = (CharacterToken)obj;
            Assert.IsTrue(token.IsValid);
            Assert.IsNull(token.ScanError);
            Assert.AreEqual(0, token.StartPosition.Position);
            Assert.AreEqual(1, token.StopPosition.Position);
            Assert.AreEqual(' ', token.Value);

            // Should be the last one
            obj = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(EofToken));
        }
コード例 #5
0
    //public Skill[] Skills { get { return skills; } }

    private void Start()
    {
        myToken = Instantiate(CharToken);

        charStats = new CharacterStats(myToken.Vitality, myToken.Strenght, myToken.Resistance, myToken.Intelligence, myToken.Agility);

        myToken.Skills.CopyTo(skills, 0);

        life = charStats.MaxLife;

        animator = GetComponent <Animator>();
        Audio    = gameObject.AddComponent <AudioSource>();

        if (animator == null)
        {
            Debug.LogWarning("animator no personagem é nulo");
        }
    }
コード例 #6
0
    IEnumerator MudarDeFaseYield(int fase, Fase faseAtual, CharacterToken inimigoStatus)
    {
        SceneManager.LoadScene(fase);
        yield return(new WaitForSeconds(0.2f));

        SetarInimigo Setar = GameObject.FindGameObjectWithTag("Setagem").GetComponent <SetarInimigo>();
        Transform    posicaoParaPersonagemPrincipal = GameObject.FindGameObjectWithTag("PlayerPosition").transform;

        if (Setar == null)
        {
            Debug.Log("Setagem é nulla");
        }
        GameObject inimigo             = Instantiate(faseAtual.tipoDeInimigo, Setar.transform);
        Character  inimigoCharacter    = inimigo.AddComponent <Enemy>();
        Character  personagemPrincipal = Instantiate(personagemPrincipalPrefab, posicaoParaPersonagemPrincipal.position, posicaoParaPersonagemPrincipal.rotation).GetComponent <Player>();

        inimigoCharacter.CharToken        = inimigoStatus;
        inimigoCharacter.currentTarget    = personagemPrincipal;
        personagemPrincipal.currentTarget = inimigoCharacter;
        BattleController bc = GameObject.FindGameObjectWithTag("BattleController").GetComponent <BattleController>();

        bc.StartCountdown();
    }
コード例 #7
0
 protected bool IsWhitespace(CharacterToken charToken)
 {
     char c = charToken.Character;
     return (c == 0x09 || c == 0x0A || c == 0x0C || c == 0x0D || c == ' ');
 }
コード例 #8
0
        public void GetType_DoesNotThrow_WhenEnumTypeIsRegexTokenType()
        {
            var token = new CharacterToken(null, 0, 0);

            Assert.DoesNotThrow(() => token.GetType <RegexTokenType>());
        }
コード例 #9
0
 public void Desequipar(CharacterToken personagem)
 {
     personagem.TakeStats(statsToAdd);
 }
コード例 #10
0
 public void Equipar(CharacterToken personagem)
 {
     personagem.AddStats(statsToAdd);
 }
コード例 #11
0
 public void MudarDeFase(int fase, Fase faseAtual, CharacterToken inimigoStatus)
 {
     this.faseAtual = faseAtual;
     objetoPai.SetActive(false);
     StartCoroutine(MudarDeFaseYield(fase, faseAtual, inimigoStatus));
 }
コード例 #12
0
 public void ResetToken()
 {
     playerToken = null;
 }
コード例 #13
0
 public void SavePlayerToken(CharacterToken ct)
 {
     playerToken = ct;
 }
コード例 #14
0
        public void GetType_ThrowsTypeAccessException_WhenEnumTypeNotRegexTokenType()
        {
            var token = new CharacterToken(null, 0, 0);

            Assert.Throws <TypeAccessException>(() => token.GetType <TestColor>());
        }