Code-switching mostly occurs where the syntaxes of the languages align in a sentence; thus, it is uncommon to switch from English to French after an adjective and before a noun, because, in French, adjectives usually follow nouns. Even unrelated languages often align syntactically at a relative clause boundary or at the boundary of other sentence sub-structures.
Linguists have made significant effort toward defining the difference between borrowing (loanword usage) and code-switching; generally, borrowing occurs in the lexicon, while code-switching occurs at either the syntax level or the utterance-construction level.
In studying the syntactic and morphological patterns of language alternation, linguists have postulated specific grammatical rules and specific syntactic boundaries for where code-switching might occur. None of these suggestions is universally accepted, however, and linguists have offered apparent counter-examples to each proposed constraint. Some proposed constraints are:
The Free-morpheme Constraint: code-switching cannot occur between bound morphemes.
The Equivalence Constraint: code-switching can occur only in positions where "the order of any two sentence elements, one before and one after the switch, is not excluded in either language." Thus, the sentence: "I like you porque eres simpático." ("I like you because you are nice.") is allowed because it obeys the relative clause formation rules of Spanish and English.
The Closed-class Constraint: closed class items (pronouns, prepositions, conjunctions, etc.), cannot be switched.
The Matrix Language Frame model distinguishes the roles of the participant languages.
The Functional Head Constraint: code-switching cannot occur between a functional head (a complementizer, a determiner, an inflection, etc.) and its complement (sentence, noun-phrase, verb-phrase).
Note that some theories, such as the Closed-class Constraint, the Matrix Language Frame model, and the Functional Head Constraint, which make general predictions based upon specific presumptions about the nature of syntax, are controversial among linguists positing alternative theories. In contrast, descriptions based on empirical analyses of corpora, such as the Equivalence Constraint, are relatively independent of syntactic theory, but the code-switching patterns they describe vary considerably among speech communities, even among those sharing the same language pairs.