This chapter deals with the morphosyntactic analysis of languages and the compilation of morphosyntactic data in digital format, with special attention to Spanish. The basic concepts of formal grammar and its typology are presented, as well as the concept of the analyser as a tool that applies formal grammars to text analysis. The computational treatment of morphosyntax includes several preprocesses, such as tokenization and the treatment of different kinds of lexical units. We distinguish between partial and full analysis, as well as different approaches to syntactic annotation: constituent analysis and the analysis of dependencies. We provide a fairly detailed presentation of the methodology used for the annotation of treebanks. We describe and analyse the basic content of the main Spanish treebanks. The approach to morphosyntax from a computational perspective also involves addressing the complexity of the analysis of real language corpora, usually extracted from the Internet, in which the language is less formal and more spontaneous. The concepts of the sentence, constituents and syntactic and semantic coherence often do not follow prescriptive rules. Finally, future lines of research are set out, concretely the definition of syntactic tagsets valid for the largest possible number of languages and the treatment of non-normative corpora and specific syntactic structures.